def __init__(self, parent, columns=7): tk.Frame.__init__(self, parent, bg="white") self._widgets = [] self.kella_algus = 9 # int(input('Sisesta, mis kellast sinu tööpäev algab: ')) + 1 self.kella_lõpp = 20 # int(input('Sisesta, mis kellast sinu tööpäev lõppeb:')) + 1 ridade_arv = abs(self.kella_lõpp - self.kella_algus) * 2 + 2 i = 2 for row in range(ridade_arv - 1): current_row = [] for column in range(columns): if column != 2: label = labels.Labels( self) # text='', borderwidth=0, width=8, bg="#a8a8a8") # print(tund.Tund.tunnid) for cls in tund.Tund.tunnid: if cls.getWeekday() + 4 == column: if cls.getTime() == str(self.kella_algus - 1) + ':15': label = labels.Labels(self, cls.getLessonName(), cls.getTime(), cls.getLocation(), cls.getDescription(), cls.getDate()) print(cls.getLessonName() + " " + str(self.kella_algus - 2) + ':15') else: if row == 0: # Kellaaegade üleval olev tühikast. label = tk.Label(self, text='', borderwidth=0, width=8) elif self.kella_algus in range( self.kella_algus, self.kella_lõpp) and i % 2 == 0: label = tk.Label(self, text=str(self.kella_algus - 1) + '.15') i += 1 elif self.kella_algus in range( self.kella_algus, self.kella_lõpp) and i % 2 != 0: label = tk.Label(self, text=str(self.kella_algus - 1) + '.45') self.kella_algus += 1 i += 1 label.grid(row=row, column=column, sticky="nsew", padx=1, pady=0.5) current_row.append(label) self._widgets.append(current_row) for column in range(columns): self.grid_columnconfigure(column, weight=1)
def __init__(self, config): """ Setup the class instance. """ self.config = config self.wram = wram.WRAMProcessor(self.config) self.labels = labels.Labels(self.config)
def refreshCalander(self): #Salvestab kalendrisse uue ülesande. for cls in tund.Tund.tunnid: index = self.getRowColumn(cls.getTime(), cls.getWeekday()) if index == None or index[0] >= self.kella_lõpp: continue try: label = labels.Labels(self, cls.getLessonName(), cls.getTime(), cls.getLocation(), cls.getDescription(), cls.getDate()) label.grid(row=index[0] + 1, column=index[1] + 1, rowspan=4, sticky="nsew", padx=(0.5, 0), pady=(0, 0.5)) label.configure(width=100, font='Sans 11') self._widgets[index[0]][index[1]] = label except: pass
def main(): if len(sys.argv) != 4: raise ValueError, "Need token file and master label file" token_h = open(sys.argv[1]) MLFs = labels.Labels() MLFs.add_mlf(sys.argv[2]) output_h = open(sys.argv[3], 'w') line_match = re.compile( '(?P<Start>\d+\.?\d*)+ (?P<Stop>[\d\.])+ "(?P<Token>.*)"') for line in token_h: match = line_match.match(line) if match: # Get information for current region (start, stop, token) = match.groups() # find class of token label_info = MLFs.access("%s.rec" % (token)) label = label_info[0][0] # pull out class label score = label_info[0][1] # log likelihood of class # write out new label information output_h.write('%f %f "%s"\n' % (start, stop, label))
def __init__(self, parent, kella_algus, kella_lõpp, url, columns=7): tk.Frame.__init__(self, parent, bg="#f4f4f2") calander.createEventList(url) self._widgets = [] self.kella_algus = kella_algus self.kella_lõpp = kella_lõpp ridade_arv = abs(self.kella_lõpp - self.kella_algus) * 2 + 2 i = 2 #Muutuja: hoiab silma peal kas kell on veerand või kolmveerand. for row in range(ridade_arv - 1): current_row = [] for column in range(columns): if column != 0: label = labels.Labels(self) ''' for cls in tund.Tund.tunnid: if cls.getWeekday() + 1 == column: if cls.getTime() == str(self.kella_algus) + ':15': label = labels.Labels(self, cls.getLessonName(), cls.getTime(), cls.getLocation(), cls.getDescription(), cls.getDate()) print(cls.getLessonName() + " " + str(self.kella_algus) + ':15')''' else: if row == 0: # Kellaaegade üleval olev tühi kast. label = tk.Label(self, text='', borderwidth=0, width=8) elif self.kella_algus in range( self.kella_algus, self.kella_lõpp) and i % 2 == 0: label = tk.Label(self, text=str(self.kella_algus) + '.15') i += 1 elif self.kella_algus in range( self.kella_algus, self.kella_lõpp) and i % 2 != 0: label = tk.Label(self, text=str(self.kella_algus) + '.45') self.kella_algus += 1 i += 1 label.grid(row=row, column=column, sticky="nsew", padx=0.5, pady=0.5) label.configure(width=8, font='Sans 11') if ridade_arv < 25: label.configure(width=8, font='Sans 12') else: label.configure(width=8, font='Sans 10') current_row.append(label) self._widgets.append(current_row) self.set(0, 0, '') self.getLabelObject(0, 1).setLessonName('Esmaspäev') self.getLabelObject(0, 2).setLessonName('Teisipäev') self.getLabelObject(0, 3).setLessonName('Kolmapäev') self.getLabelObject(0, 4).setLessonName('Neljapäev') self.getLabelObject(0, 5).setLessonName('Reede') self.getLabelObject(0, 6).setLessonName('Laupäev') self.getLabelObject(0, 7).setLessonName('Pühapäev') self.kella_algus = kella_algus self.kella_lõpp = kella_lõpp self.refreshCalander() for column in range(columns): self.grid_columnconfigure(column, weight=1)