def __init__(self,parent=None): 'constructor' Frame.__init__(self, parent) # If you use pack for the widgets in make_widgets, change # this to pack self.grid() CreditCard.make_widgets(self)
def __init__(self,parent=None): 'constructor' Frame.__init__(self, parent) self.pack() self.count = 0 Game.make_widgets(self) Game.new_game(self)
def __init__(self, parent, handler): '''Initialization method.''' Frame.__init__(self, parent) button_frame = Frame(self) button_frame.pack(side=TOP) self.deal_button = Button(button_frame, text="Deal", command=lambda: handler("deal")) self.deal_button.pack(side=LEFT, padx=5, pady=5) self.quit_button = Button(button_frame, text="Quit", command=lambda: handler("quit")) self.quit_button.pack(side=RIGHT, padx=5, pady=5) self.exchange_button = Button(button_frame, text="Exchange", command=lambda: handler("exchange")) self.exchange_button.pack(side=RIGHT, padx=5, pady=5) self.show_button = Button(button_frame, text="Show", command=lambda: handler("show")) self.show_button.pack(side=RIGHT, padx=5, pady=5) label_frame = Frame(self) label_frame.pack(side=BOTTOM) self.status_label = Label(label_frame, relief=SUNKEN) self.set_status_text("No text to show") self.status_label.pack(side=TOP, padx=5, pady=5)
def __init__(self, parent): Frame.__init__(self, parent) self.text = Text(self) self.text.pack(side="top", fill="both", expand=True) self.text.tag_configure("current", background="#e9e9e9") self.highlight_current_line()
def __init__(self, master=None): Frame.__init__(self, master) self.pack(expand=1, fill='both') self.master.geometry('1440x900') paned_window = PanedWindow(self) self.treeview_kspelements = TreeviewKSPElements(self) self.treeview_kspobjects = TreeviewKSPObjects(self) paned_window.pack(expand=1, fill='both') paned_window.add(self.treeview_kspelements) paned_window.add(self.treeview_kspobjects) menubar = Menu(self) filemenu = Menu(self) filemenu.add_command(label='Open', command=self._open) filemenu.add_command(label='Save', command=self._save) filemenu.add_command(label='Save As', command=self._save_as) filemenu.add_separator() filemenu.add_command(label='Exit', command=self.master.destroy) menubar.add_cascade(menu=filemenu, label='File') insertmenu = Menu(self) insertmenu.add_command(label='KSP Element', command=self._insert_element, state='disabled') insertmenu.add_command(label='KSP Object', command=self._insert_object) menubar.add_cascade(menu=insertmenu, label='Insert') self.master.config(menu=menubar)
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.pack() self._lbl = Label(self, text="no parameters") self._lbl.pack()
def __init__(self, master=None): # Avoiding to send it continuously. self.lock = False Frame.__init__(self, master) self.grid() self.master = master # Setting for ComboBox. self.url_lang_combobox_str = StringVar() self.url_lang_combobox_list = lang_list # UI components. self.receiver_email_text = Label(self, text="Receiver:") self.receiver_email_field = Entry(self, width=50) self.subject_text = Label(self, text='Subject:') self.subject_field = Entry(self, width=50) self.receiver_name_text = Label(self, text='Name:') self.receiver_name_field = Entry(self, width=50) self.url_lang_text = Label(self, text='Link lang:') self.url_lang_combobox = Combobox(self, textvariable=self.url_lang_combobox_str, values=self.url_lang_combobox_list, state='readonly') self.send_progressbar = Progressbar(self, orient='horizontal', length=500, mode='determinate', maximum=300) self.send_button = Button(self, text='Send', command=self._send_mail) self.quit_button = Button(self, text='Exit', command=self.__exit) self.log_msg_text = ScrolledText(self) # Attachment. self.mail_attachment_list = attachment_list[:] self.url_lang_link_title = None self.url_lang_link = copy.deepcopy(content_link) # Mailer self._mailer = None # Let Mailer can control components. Mailer.window_content = self self.__create_widgets()
def __init__(self, parent, n): Frame.__init__(self, parent) self.parent = parent; self.parent.maxsize(1200,720) self.parent.minsize(1200,720) self.initUI() self.placeWindow(n)
def __init__(self, master=None, bg='black', height=1000, width=1000): Frame.__init__(self, master, bg='black', height=1000, width=1000) #self.title("CTA Train Tracker ") self.driv = driver.Driver() self.pack() self.memory='' lines.make_widgets(self)
def __init__(self, bg='black', parent=None): Frame.__init__(self, bg='black', parent=None) #self.title("CTA Train Tracker ") self.driv = driver.Driver() self.pack() self.memory='' traintracker.make_widgets(self)
def __init__(self, parent): # super(createSets,self).__init__(parent) Frame.__init__(self, parent) self.parent = parent self.grid(row=0, column=0) self.parentWindow = 0 self.listBox = Listbox(self, selectmode=EXTENDED) self.listBox.grid(row=1, column=1) for item in ["one", "two", "three", "four"]: self.listBox.insert(END, item) self.buttonDel = Button(self, text="delite selected class", command=self.del_selected) # lambda ld=self.listBox:ld.delete(ANCHOR)) self.buttonDel.grid(row=0, column=0) self.entry = Entry(self, state=NORMAL) # self.entry.focus_set() self.entry.insert(0, "default") self.entry.grid(row=1, column=0) self.buttonInsert = Button(self, text="add new class", command=self.add) self.buttonInsert.grid(row=0, column=1) self.buttonDone = Button(self, text="done", command=self.done) self.buttonDone.grid(row=2, column=0)
def __init__(self): """ Create the initial application GUI environment (tool bars, and other static elements) """ Frame.__init__(self, self.root) self.thread_entry_field = '' # Hold both search string, and drives autoRefresh logic self.menuBar = Menu() self.fileMenu = Menu(self.menuBar, tearoff=0) self.menuBar.add_cascade(label="File", menu=self.fileMenu, underline=1) self.fileMenu.add_command(label="Quit", command=self.root.destroy, underline=1) self.optionsMenu = Menu(self.menuBar, tearoff=0) self.menuBar.add_cascade(label="Options", menu=self.optionsMenu) self.optionsMenu.add_command(label="Settings", command=self.editSettings, underline=1) self.helpMenu = Menu(self.menuBar, tearoff=0) self.menuBar.add_cascade(label="Help", menu=self.helpMenu) self.helpMenu.add_command(label="Help", command=self.program_help, underline=1) self.helpMenu.add_command(label="About", command=self.program_about, underline=1) self.master.config(menu=self.menuBar) self.topFrame = Frame() self.thread_entry_box = Entry(self.topFrame) self.thread_entry_box.insert(0, self.DEFAULT_THREAD_TEXT) self.thread_entry_box.bind('<Return>', lambda event: self.add_thread_GUI()) # Bind needs to send the event to the handler self.thread_entry_box.pack(side='left', fill='x', expand='True', padx=5) self.add_thread_btn = Button(self.topFrame) self.add_thread_btn['text'] = 'Add New Thread' self.add_thread_btn['command'] = lambda: self.add_thread_GUI() self.add_thread_btn.pack(side='left', padx=0) self.topFrame.pack(fill='x') self.create_thread_frame()
def __init__(self): ''' Constructor Initialise GameOfLife object Build the gui, bind events and initialise the display ''' # Encasing frame tk = Tk() Frame.__init__(self, master=tk) # Grid frame self._grid = GridWidget(self, X_SIZE, Y_SIZE) for row in self._grid.get_cells(): for cell in row: cell.bind('<Button-1>', self._cell_listener) # buttons self._next_button = NextButton(master=self) self._next_button.bind('<Button-1>', self._next_step_button_listener) # Set layout self._grid.grid(row=0, column=0) self._next_button.grid(row=0, column=1) # Game of life self._gol = GameOfLife(RuleSetStandard(), self._grid) self.pack() self._grid.pack() self._next_button.pack()
def __init__(self, master=None): Frame.__init__(self, master) self.creatures_names_list = [""] * 12 self.environment = StringVar() self.chance = StringVar() Label(self, text="Environment of the Encounter :").grid(row=0, column=0, columnspan=3) Label(self, text="Chance of the Encounter :").grid(row=1, column=0, columnspan=3) Label(self, text=" %").grid(row=1, column=4) Label(self, text="1 :").grid(row=2, column=0) Label(self, text="2 :").grid(row=3, column=0) Label(self, text="3 :").grid(row=4, column=0) Label(self, text="4 :").grid(row=5, column=0) Label(self, text="5 :").grid(row=6, column=0) Label(self, text="6 :").grid(row=7, column=0) Label(self, text="7 :").grid(row=2, column=4) Label(self, text="8 :").grid(row=3, column=4) Label(self, text="9 :").grid(row=4, column=4) Label(self, text="10 :").grid(row=5, column=4) Label(self, text="11 :").grid(row=6, column=4) Label(self, text="12 :").grid(row=7, column=4) Label(self, text="AC :").grid(row=3, column=7) Label(self, text="HP :").grid(row=4, column=7) Label(self, text="ATK :").grid(row=5, column=7) Label(self, text="DMG :").grid(row=6, column=7) Label(self, text="NUMBER :").grid(row=7, column=7) Label(self, text="SAVES:").grid(row=8, column=7) Label(self, text="ALIGN :").grid(row=9, column=7) Label(self, text="XP :").grid(row=10, column=7)
def __init__(self, parent): Frame.__init__(self, parent, background="white") self.parent = parent self.parent.title("Centered window") self.pack(fill=BOTH, expand=1) self.centerWindow()
def __init__(self, parent): Frame.__init__(self, parent, background="white") self.parent = parent self.parent.title("Test title") self.fullscreen()
def __init__(self, parent): """ This method creates a new, emtpy LpoView. """ Frame.__init__(self, parent) self.__parent = parent self.__initUI() self.__lpo = None
def __init__(self, parent, use_large_images=False, num_cards=3): '''Initialization method.''' Frame.__init__(self, parent) # Set playing cards and miscellaneous variables self._deck = pcards.Deck() self._hand = pcards.Hand(self._deck) self._num_cards = num_cards self._parent = parent # Create and pack card hand widget card_images = (pcards.CardImagesLarge if use_large_images else pcards.CardImagesSmall) self._chw = pcards.CardHandWidget(self, card_images, numcards=self._num_cards, relief=SUNKEN, borderwidth=2) self._chw.pack(side=TOP, padx=5, pady=5) # Create and pack control buttons widget button_defs = [ ("Deal", self._deal), ("Exchange", self._exchange), ("Clear", self._clear), ("Quit", self._quit) ] bbw = ButtonBarWidget(self, button_defs) bbw.pack(side=BOTTOM)
def __init__(self, parent, *args, **kw): Frame.__init__(self, parent, *args,**kw) self.e=Entry(self, text='Message') self.e.delete(0,'end') self.e.pack() self.makebuttons() self.pack(expand='true',fill='x')
def __init__(self, parent, analysis): Frame.__init__(self, parent) # analysis is a lua table self.analysis = analysis self.parent = parent self.initUI()
def __init__(self, parent): Frame.__init__(self, parent, background="white") self.parent = parent self.initUI() self.addButtons() self.addMainContent()
def __init__(self,master=None, thread=None): Frame.__init__(self, master) self.controlThread=thread self.stringVar=StringVar() self.grid() self.createWidgets()
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.createWidgets() #self.sniffUrl() self.count_down()
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.files = ["file1", "file2"] self.initUI()
def __init__(self, parent, game): self.game = game self.parent = parent Frame.__init__(self, parent) self.row, self.col = 0, 0 self.__initUI()
def __init__(self, parent): Frame.__init__(self, parent, background="white") self.plugin = mariospicross self.parent = parent self.initUI()
def __init__(self, points, master=None): Frame.__init__(self, master) """ Give the number of positive units on X, number of positive units on Y and the unit size """ self.dimensions = None self.canvas = tkinter.Canvas() self.createAutoSizeGraphic(points)
def __init__(self, parent): Frame.__init__(self, parent, background="white") self.parent = parent self.pack(fill=TkC.BOTH, expand=1) self.path= os.path.dirname(os.path.realpath(sys.argv[0])) with open(self.path + '/pimenu.yaml', 'r') as f: self.doc = yaml.load(f) self.show_items(self.doc)
def __init__(self, parent, text): """Very simple label class. Might have been overkill, I originally intended there to be more to this class, but it proved unnecesary for this example. """ Frame.__init__(self, parent) self.pack() self.label = Label(self, text=text) self.label.pack()
def __init__(self, parent, list_model_factory, label_text): Frame.__init__(self, parent) scrollbar = Scrollbar(self, orient=VERTICAL) Label(self, text=label_text).pack() self.check_list_box = ProgressListBox(self, scrollbar, list_model_factory) scrollbar.config(command=self.check_list_box.yview) scrollbar.pack(side=RIGHT, fill=Y) self.check_list_box.pack(side=LEFT, fill=BOTH, expand=1)
def __init__(self, name, *args, **kwargs): Frame.__init__(self, *args, **kwargs) self.TextData = Text(self) self.LabelData = Label(self) path_asli = '..\\Data Lagu\\asli\\reff' self.filepath_asli = [ os.path.join(path_asli, fname) for fname in os.listdir(path_asli) if fname.endswith('.wav') ] self.idx_tests = { '01': 0, '02': 1, '03': 2, '04': 3, '05': 4, '06': 5, '07': 6, '08': 7, '09': 8, '10': 9 } lblInputLagu = Label(self, text="Input Lagu") lblInputLagu.grid(row=0, column=0) lblLagu = Label(self, text="Lagu") lblLagu.grid(row=1, column=0) self.lblFilepath = Label(self, text="...", width="40", background="white") self.lblFilepath.grid(row=1, column=1, pady=10, columnspan=3, sticky="W") self.BtnBrowse = Button(self, text="Pilih", command=self.fileDialog) self.BtnBrowse.grid(row=1, column=4, pady=10, padx=10, sticky="E") self.btnReset = Button(self, text="Reset", command=self.reset) self.btnReset.grid(row=1, column=5) lblFbank = Label(self, text="Filter Bank") lblFbank.grid(row=2, column=0, padx=5, pady=10, sticky="E") self.fbank = StringVar(value="20") entFbank = Entry(self, textvariable=self.fbank) entFbank.grid(row=2, column=1, sticky="W", pady=10) lblWinlen = Label(self, text="WinLen") lblWinlen.grid(row=2, column=2, sticky="E") self.winlen = StringVar(value="0.05") entWinlen = Entry(self, textvariable=self.winlen) entWinlen.grid(row=2, column=3, sticky="W", pady=10) lblWinstep = Label(self, text="WinStep") lblWinstep.grid(row=2, column=4, sticky="E") self.winstep = StringVar(value="0.025") entWinstep = Entry(self, textvariable=self.winstep) entWinstep.grid(row=2, column=5, sticky="W", pady=10) self.BtnIdentifying = Button(self, text="Identifikasi", pady=5, padx=10, command=self.identifikasi) self.BtnIdentifying.grid(row=3, column=0, columnspan=4, pady=10, padx=10, sticky="E") lblIdentLagu = Label(self, text="Identifikasi Lagu") lblIdentLagu.grid(row=4, column=0, padx=5) lblHasil = Label(self, text="Hasil") lblHasil.grid(row=5, column=0) self.hCover = StringVar(value="") entHasilCover = Entry(self, textvariable=self.hCover) entHasilCover.grid(row=5, column=1, sticky="E") lblEqual = Label(self, text="=") lblEqual.grid(row=5, column=2) self.hAsli = StringVar(value="") entHasilAsli = Entry(self, textvariable=self.hAsli) entHasilAsli.grid(row=5, column=3) self.kesimpulan = StringVar(value="") entKesimpulan = Entry(self, textvariable=self.kesimpulan) entKesimpulan.grid(row=6, column=0, padx=10, pady=5)
def __init__(self, parent): Frame.__init__(self, parent) parent.title('Snake game') self.board = Board(parent) self.pack()
def __init__(self, master, columns, column_weights=None, cnf={}, **kw): """ Construct a new multi-column listbox widget. :param master: The widget that should contain the new multi-column listbox. :param columns: Specifies what columns should be included in the new multi-column listbox. If ``columns`` is an integer, the it is the number of columns to include. If it is a list, then its length indicates the number of columns to include; and each element of the list will be used as a label for the corresponding column. :param cnf, kw: Configuration parameters for this widget. Use ``label_*`` to configure all labels; and ``listbox_*`` to configure all listboxes. E.g.: >>> mlb = MultiListbox(master, 5, label_foreground='red') """ # If columns was specified as an int, convert it to a list. if isinstance(columns, int): columns = list(range(columns)) include_labels = False else: include_labels = True if len(columns) == 0: raise ValueError("Expected at least one column") # Instance variables self._column_names = tuple(columns) self._listboxes = [] self._labels = [] # Pick a default value for column_weights, if none was specified. if column_weights is None: column_weights = [1] * len(columns) elif len(column_weights) != len(columns): raise ValueError('Expected one column_weight for each column') self._column_weights = column_weights # Configure our widgets. Frame.__init__(self, master, **self.FRAME_CONFIG) self.grid_rowconfigure(1, weight=1) for i, label in enumerate(self._column_names): self.grid_columnconfigure(i, weight=column_weights[i]) # Create a label for the column if include_labels: l = Label(self, text=label, **self.LABEL_CONFIG) self._labels.append(l) l.grid(column=i, row=0, sticky='news', padx=0, pady=0) l.column_index = i # Create a listbox for the column lb = Listbox(self, **self.LISTBOX_CONFIG) self._listboxes.append(lb) lb.grid(column=i, row=1, sticky='news', padx=0, pady=0) lb.column_index = i # Clicking or dragging selects: lb.bind('<Button-1>', self._select) lb.bind('<B1-Motion>', self._select) # Scroll whell scrolls: lb.bind('<Button-4>', lambda e: self._scroll(-1)) lb.bind('<Button-5>', lambda e: self._scroll(+1)) lb.bind('<MouseWheel>', lambda e: self._scroll(e.delta)) # Button 2 can be used to scan: lb.bind('<Button-2>', lambda e: self.scan_mark(e.x, e.y)) lb.bind('<B2-Motion>', lambda e: self.scan_dragto(e.x, e.y)) # Dragging outside the window has no effect (diable # the default listbox behavior, which scrolls): lb.bind('<B1-Leave>', lambda e: 'break') # Columns can be resized by dragging them: l.bind('<Button-1>', self._resize_column) # Columns can be resized by dragging them. (This binding is # used if they click on the grid between columns:) self.bind('<Button-1>', self._resize_column) # Set up key bindings for the widget: self.bind('<Up>', lambda e: self.select(delta=-1)) self.bind('<Down>', lambda e: self.select(delta=1)) self.bind('<Prior>', lambda e: self.select(delta=-self._pagesize())) self.bind('<Next>', lambda e: self.select(delta=self._pagesize())) # Configuration customizations self.configure(cnf, **kw)
def __init__(self, name, *args, **kwargs): Frame.__init__(self, *args, **kwargs) self.TextTraining = Text(self) path_asli = '..\\Data Lagu\\asli\\reff' self.filepath_asli = [ os.path.join(path_asli, fname) for fname in os.listdir(path_asli) if fname.endswith('.wav') ] self.idx_tests = { '01': 0, '02': 1, '03': 2, '04': 3, '05': 4, '06': 5, '07': 6, '08': 7, '09': 8, '10': 9 } frInput = Frame(self) frInput.grid(row=0, column=0, columnspan=3, padx=10, pady=10) lblJudulTA = Label(frInput, text="JUDUL APLIKASI TUGAS AKHIR") lblJudulTA.grid(row=0, column=0, pady=10, columnspan=3) lblParameter = Label(frInput, text="Parameter") lblParameter.grid(row=2, column=0, sticky="W") lblFilterBank = Label(frInput, text="Filter bank") lblFilterBank.grid(row=3, column=0, sticky="W") lblTitik2 = Label(frInput, text=":") lblTitik2.grid(row=3, column=1) self.strFilterBank = StringVar(value="20") entFilterBank = Entry(frInput, textvariable=self.strFilterBank) entFilterBank.grid(row=3, column=2) lblPFrame = Label(frInput, text="Panjang frame") lblPFrame.grid(row=4, column=0, sticky="W") lblTitik2 = Label(frInput, text=":") lblTitik2.grid(row=4, column=1) self.strPFrame = StringVar(value="0.5") entPFrame = Entry(frInput, textvariable=self.strPFrame) entPFrame.grid(row=4, column=2) lblOvFrame = Label(frInput, text="Overlapping frame") lblOvFrame.grid(row=5, column=0, sticky="W") lblTitik2 = Label(frInput, text=":") lblTitik2.grid(row=5, column=1) self.strOvFrame = StringVar(value="0.25") entOvFrame = Entry(frInput, textvariable=self.strOvFrame) entOvFrame.grid(row=5, column=2) btnReset = Button(frInput, text="RESET", width="10", command=self.reset) btnReset.grid(row=6, column=0, columnspan=2, padx=10, pady=10) btnCari = Button(frInput, text="START", width="10", command=self.testing) btnCari.grid(row=6, column=2, pady=10) frHasil = Frame(self) frHasil.grid(row=1, column=0, padx=10) lblHasilIdent = Label(frHasil, text="Hasil Identifikasi") lblHasilIdent.grid(row=0, column=0, columnspan=3) self.frmTabelHasil = Frame(frHasil) self.frmTabelHasil.grid(row=1, column=0, columnspan=3) #self.scrollFrame = ScrollFrame(self.frmTabelHasil) #self.scrollFrame.pack(side="top", fill="both", expand=True) lblNo = Label(self.frmTabelHasil, text="No", width="5") lblNo.grid(row=0, column=0) lblLagu = Label(self.frmTabelHasil, text="Lagu", width="10") lblLagu.grid(row=0, column=1, padx=5) lblTKemiripan = Label(self.frmTabelHasil, text="Jml benar", width="10") lblTKemiripan.grid(row=0, column=2) self.lblTableResults1 = [] self.lblTableResults2 = [] self.lblTableResults3 = [] for i in range(1, 11): self.lblTableResults1.append( Label(self.frmTabelHasil, text="", width="5")) self.lblTableResults1[i - 1].grid(row=i, column=0) self.lblTableResults2.append( Label(self.frmTabelHasil, text="", width="10")) self.lblTableResults2[i - 1].grid(row=i, column=1) self.lblTableResults3.append( Label(self.frmTabelHasil, text="", width="10")) self.lblTableResults3[i - 1].grid(row=i, column=2) lblAkurasi = Label(frHasil, text="Akurasi") lblAkurasi.grid(row=2, column=0, padx=10, pady=10) lblEqual = Label(frHasil, text="=") lblEqual.grid(row=2, column=1) self.akurasi = StringVar(value="") entAkurasi = Entry(frHasil, textvariable=self.akurasi) entAkurasi.grid(row=2, column=2) self.lblWaktuProses = Label(frHasil, text="") self.lblWaktuProses.grid(row=3, column=0, columnspan=3, pady=5, padx=5) #self.frmTabelHasil2 = Frame(frHasil) #self.frmTabelHasil2.grid(row=2, column=1, padx=10) #self.frmTabelHasil3 = Frame(frHasil) #self.frmTabelHasil3.grid(row=2, column=2) '''
def __init__(self, master = None): Frame.__init__(self, master) self.pack(padx = 8, pady = 8) self.createWidgets()
def __init__(self, parent): Frame.__init__(self, parent) self.pack(expand=YES, fill=BOTH) self.config(relief=RIDGE, border=2)
def __init__(self, parent=None): Frame.__init__(self, parent) self.pack() self.makeWidgets()
def __init__(self, master): Frame.__init__(self, master) self.pack() self.create_widgets()
def __init__(self, parent, updater): Frame.__init__(self, parent) self.updater = updater
def __init__(self, master, columns, column_weights=None, column_minwidths=None, height=500, minwidth=20, minheight=20, padx=5, pady=5, cell_font=None, cell_foreground="black", cell_background="white", cell_anchor=W, header_font=None, header_background="white", header_foreground="black", header_anchor=CENTER, bordercolor="#999999", innerborder=True, outerborder=True, stripped_rows=("#EEEEEE", "white"), on_change_data=None, mousewheel_speed=2, scroll_horizontally=False, scroll_vertically=True): outerborder_width = 1 if outerborder else 0 Frame.__init__(self, master, bd=0) self._cell_background = cell_background self._cell_foreground = cell_foreground self._cell_font = cell_font self._cell_anchor = cell_anchor self._stripped_rows = stripped_rows self._padx = padx self._pady = pady self._bordercolor = bordercolor self._innerborder_width = 1 if innerborder else 0 self._data_vars = [] self._columns = columns self._number_of_rows = 0 self._number_of_columns = len(columns) self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(1, weight=1) self._head = Frame(self, highlightbackground=bordercolor, highlightcolor=bordercolor, highlightthickness=outerborder_width, bd=0) self._head.grid(row=0, column=0, sticky=E + W) header_separator = False if outerborder else True for j in range(len(columns)): column_name = columns[j] header_cell = Header_Cell(self._head, text=column_name, borderwidth=self._innerborder_width, font=header_font, background=header_background, foreground=header_foreground, padx=padx, pady=pady, bordercolor=bordercolor, anchor=header_anchor, separator=header_separator) header_cell.grid(row=0, column=j, sticky=N + E + W + S) add_scrollbars = scroll_horizontally or scroll_vertically if add_scrollbars: if scroll_horizontally: xscrollbar = Scrollbar(self, orient=HORIZONTAL) xscrollbar.grid(row=2, column=0, sticky=E + W) else: xscrollbar = None if scroll_vertically: yscrollbar = Scrollbar(self, orient=VERTICAL) yscrollbar.grid(row=1, column=1, sticky=N + S) else: yscrollbar = None scrolling_area = Scrolling_Area( self, width=self._head.winfo_reqwidth(), height=height, scroll_horizontally=scroll_horizontally, xscrollbar=xscrollbar, scroll_vertically=scroll_vertically, yscrollbar=yscrollbar) scrolling_area.grid(row=1, column=0, sticky=E + W) self._body = Frame(scrolling_area.innerframe, highlightbackground=bordercolor, highlightcolor=bordercolor, highlightthickness=outerborder_width, bd=0) self._body.pack() def on_change_data(): scrolling_area.update_viewport() else: self._body = Frame(self, height=height, highlightbackground=bordercolor, highlightcolor=bordercolor, highlightthickness=outerborder_width, bd=0) self._body.grid(row=1, column=0, sticky=N + E + W + S) if column_weights is None: for j in range(len(columns)): self._body.grid_columnconfigure(j, weight=1) else: for j, weight in enumerate(column_weights): self._body.grid_columnconfigure(j, weight=weight) if column_minwidths is not None: for j, minwidth in enumerate(column_minwidths): if minwidth is None: header_cell = self._head.grid_slaves(row=0, column=j)[0] minwidth = header_cell.winfo_reqwidth() self._body.grid_columnconfigure(j, minsize=minwidth) else: for j in range(len(columns)): header_cell = self._head.grid_slaves(row=0, column=j)[0] minwidth = header_cell.winfo_reqwidth() self._body.grid_columnconfigure(j, minsize=minwidth) self._on_change_data = on_change_data
def __init__(self, master=None): Frame.__init__(self, master) self.master = master self.init_window()
def __init__(self, master, width=None, anchor=N, height=None, mousewheel_speed=2, scroll_horizontally=True, xscrollbar=None, scroll_vertically=True, yscrollbar=None, outer_background=None, inner_frame=Frame, **kw): Frame.__init__(self, master, class_=self.__class__) if outer_background: self.configure(background=outer_background) self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(0, weight=1) self._width = width self._height = height self.canvas = Canvas(self, background=outer_background, highlightthickness=0, width=width, height=height) self.canvas.grid(row=0, column=0, sticky=N + E + W + S) if scroll_vertically: if yscrollbar is not None: self.yscrollbar = yscrollbar else: self.yscrollbar = Scrollbar(self, orient=VERTICAL) self.yscrollbar.grid(row=0, column=1, sticky=N + S) self.canvas.configure(yscrollcommand=self.yscrollbar.set) self.yscrollbar['command'] = self.canvas.yview else: self.yscrollbar = None if scroll_horizontally: if xscrollbar is not None: self.xscrollbar = xscrollbar else: self.xscrollbar = Scrollbar(self, orient=HORIZONTAL) self.xscrollbar.grid(row=1, column=0, sticky=E + W) self.canvas.configure(xscrollcommand=self.xscrollbar.set) self.xscrollbar['command'] = self.canvas.xview else: self.xscrollbar = None self.rowconfigure(0, weight=1) self.columnconfigure(0, weight=1) self.innerframe = inner_frame(self.canvas, **kw) self.innerframe.pack(anchor=anchor) self.canvas.create_window(0, 0, window=self.innerframe, anchor='nw', tags="inner_frame") self.canvas.bind('<Configure>', self._on_canvas_configure) Mousewheel_Support(self).add_support_to(self.canvas, xscrollbar=self.xscrollbar, yscrollbar=self.yscrollbar)
def __init__(self, master): Frame.__init__(self, master) self.parent = master
def __init__(self, master, *args, **kwargs): Frame.__init__(self, master, *args, **kwargs) self.createWidgets()
def __init__(self, name, *args, **kwargs): Frame.__init__(self, *args, **kwargs) self.TextTraining = Text(self) path_asli = '..\\Data Lagu\\asli\\reff' self.filepath_asli = [ os.path.join(path_asli, fname) for fname in os.listdir(path_asli) if fname.endswith('.wav') ] self.idx_tests = { '01': 0, '02': 1, '03': 2, '04': 3, '05': 4, '06': 5, '07': 6, '08': 7, '09': 8, '10': 9 } lblTop = Label(self, text="Pengujian Data Uji") lblTop.grid(row=0, column=0) lblFbank = Label(self, text="Filter Bank") lblFbank.grid(row=1, column=0, padx=5, pady=10, sticky="E") self.fbank = StringVar(value="20") entFbank = Entry(self, textvariable=self.fbank) entFbank.grid(row=1, column=1, sticky="W", pady=10) lblWinlen = Label(self, text="WinLen") lblWinlen.grid(row=1, column=2, sticky="E") self.winlen = StringVar(value="0.05") entWinlen = Entry(self, textvariable=self.winlen) entWinlen.grid(row=1, column=3, sticky="W", pady=10) lblWinstep = Label(self, text="WinStep") lblWinstep.grid(row=1, column=4, sticky="E") self.winstep = StringVar(value="0.025") entWinstep = Entry(self, textvariable=self.winstep) entWinstep.grid(row=1, column=5, sticky="W", pady=10) btnUji = Button(self, text="Uji", command=self.testing) btnUji.grid(row=2, column=3) btnReset = Button(self, text="Reset", command=self.reset) btnReset.grid(row=2, column=5) lblHasil = Label(self, text="Hasil Pengujian") lblHasil.grid(row=3, column=0) self.frmTabelHasil = Frame(self) self.frmTabelHasil.grid(row=4, column=0, columnspan=6) self.scrollFrame = ScrollFrame(self.frmTabelHasil) self.scrollFrame.pack(side="top", fill="both", expand=True) lblLaguAsli = Label(self.scrollFrame.viewPort, text="Lagu Asli", width="20") lblLaguAsli.grid(row=0, column=0) lblBatasTabel = Label(self.scrollFrame.viewPort, text="|") lblBatasTabel.grid(row=0, column=1) lblHasilUji = Label(self.scrollFrame.viewPort, text="Hasil", width="20") lblHasilUji.grid(row=0, column=2) lblAkurasi = Label(self, text="Akurasi") lblAkurasi.grid(row=5, column=0, padx=10, pady=10) lblEqual = Label(self, text="=") lblEqual.grid(row=5, column=1) self.akurasi = StringVar(value="") entAkurasi = Entry(self, textvariable=self.akurasi) entAkurasi.grid(row=5, column=2)
def __init__(self, master=None): Frame.__init__(self, master) #窗口大小位置 self.master.geometry("600x400+100+400") #长x宽+x+y self.pack() self.createWidgets()
def __init__(self, master=None): Frame.__init__(self, master=master, bg='gray', width=600, height=400) self.shown_image = None self.ratio = 0 self.canvas = Canvas(self, bg="gray", width=600, height=400) self.canvas.place(relx=0.5, rely=0.5, anchor=CENTER)
def __init__(self, master): Frame.__init__(self, master) self.grid() self.folder = '' self.create_widgets()
def __init__(self, master=None): Frame.__init__(self, master) self.master = master self.tl_bg = "#EEEEEE" self.tl_bg2 = "#EEEEEE" self.tl_fg = "#000000" self.font = "Verdana 10" menu = Menu(self.master) self.master.config(menu=menu, bd=5) file = Menu(menu, tearoff=0) menu.add_cascade(label="File", menu=file) file.add_command(label="Clear Chat", command=self.clear_chat) file.add_command(label="Exit", command=self.chatexit) options = Menu(menu, tearoff=0) menu.add_cascade(label="Options", menu=options) # font font = Menu(options, tearoff=0) options.add_cascade(label="Font", menu=font) font.add_command(label="Default", command=self.font_change_default) font.add_command(label="Times", command=self.font_change_times) font.add_command(label="System", command=self.font_change_system) font.add_command(label="Helvetica", command=self.font_change_helvetica) font.add_command(label="Fixedsys", command=self.font_change_fixedsys) help_option = Menu(menu, tearoff=0) menu.add_cascade(label="Help", menu=help_option) self.text_frame = Frame(self.master, bd=6) self.text_frame.pack(expand=True, fill=BOTH) self.text_box_scrollbar = Scrollbar(self.text_frame, bd=0) self.text_box_scrollbar.pack(fill=Y, side=RIGHT) self.text_box = Text(self.text_frame, yscrollcommand=self.text_box_scrollbar.set, state=DISABLED, bd=1, padx=6, pady=6, spacing3=8, wrap=WORD, bg=None, font="Verdana 10", relief=GROOVE, width=10, height=1) self.text_box.pack(expand=True, fill=BOTH) self.text_box_scrollbar.config(command=self.text_box.yview) self.entry_frame = Frame(self.master, bd=1) self.entry_frame.pack(side=LEFT, fill=BOTH, expand=True) self.entry_field = Entry(self.entry_frame, bd=1, justify=LEFT) self.entry_field.pack(fill=X, padx=6, pady=6, ipady=3) self.send_button_frame = Frame(self.master, bd=0) self.send_button_frame.pack(fill=BOTH) self.good_Radiobutton_frame = Frame(self.master, bd=0) self.good_Radiobutton_frame.pack() self.notgood_Radiobutton_frame = Frame(self.master, bd=1) self.notgood_Radiobutton_frame.pack() self.send_button = Button( self.send_button_frame, text="Send", width=5, relief=GROOVE, bg='white', bd=1, command=lambda: self.send_message_insert(None), activebackground="#FFFFFF", activeforeground="#000000") self.send_button.pack(side=LEFT, ipady=8) def positive_feedbacks(): loaded_pos = np.load('positive_feedbacks.npy') loaded_neg = np.load('negative_feedbacks.npy') selection = "accuracy based on user feedbacks : " + str( (loaded_pos / (loaded_pos + loaded_neg))) label.config(text=selection) loaded = np.load('positive_feedbacks.npy') np.save("positive_feedbacks", int(loaded) + 1) def negative_feedbacks(): loaded_pos = np.load('positive_feedbacks.npy') loaded_neg = np.load('negative_feedbacks.npy') selection = "accuracy based on user feedbacks : " + str( (loaded_pos / (loaded_pos + loaded_neg))) label.config(text=selection) loaded = np.load('negative_feedbacks.npy') np.save("negative_feedbacks", int(loaded) + 1) var = IntVar() self.good_Radiobutton = Radiobutton(self.good_Radiobutton_frame, text="Good", variable=var, value=1, command=positive_feedbacks) self.good_Radiobutton.pack(side=LEFT, ipady=8) self.notgood_Radiobutton = Radiobutton(self.notgood_Radiobutton_frame, text="Not Good", variable=var, value=2, command=negative_feedbacks) self.notgood_Radiobutton.pack(side=LEFT, ipady=8) self.master.bind("<Return>", self.send_message_insert) self.last_sent_label(date="No messages sent.") #setting the background color to blue self.master.config(bg="#263b54") self.text_frame.config(bg="#263b54") self.text_box.config(bg="#1c2e44", fg="#FFFFFF") self.entry_frame.config(bg="#263b54") self.entry_field.config(bg="#1c2e44", fg="#FFFFFF", insertbackground="#FFFFFF") self.send_button_frame.config(bg="#263b54") self.send_button.config(bg="#1c2e44", fg="#FFFFFF", activebackground="#1c2e44", activeforeground="#FFFFFF") self.good_Radiobutton_frame.config(bg="#263b54") self.good_Radiobutton.config(bg="#1c2e44", fg="#FFFFFF") self.notgood_Radiobutton_frame.config(bg="#263b54") self.notgood_Radiobutton.config(bg="#1c2e44", fg="#FFFFFF") self.sent_label.config(bg="#263b54", fg="#FFFFFF")
def __init__(self, parent): Frame.__init__(self, parent, background = 'white') self.parent = parent self.contador = 0 self.color = 'lightgreen' self.Igrafico()
def __init__(self, *args, **kwargs): Frame.__init__(self, master=None) self.master.title('Locadora 4x4') self.master.geometry('1500x850+0+0') self.master.resizable(0, 0) # impede de maximizar self.master['bg'] = '#c9c9ff' self.frame1 = Frame(self.master) self.frame2 = Frame(self.master) self.frame3 = Frame(self.master) self.frame2.pack(side='left') self.frame2.place(relx=.4, rely=.5, anchor="e") self.frame1.pack() self.frame1.place(relx=.4, rely=.5, anchor="w") self.frame3.pack() self.frame3.place(relx=.5, rely=.1, anchor="n") self.heading = Label(self.frame3, text="4x4 Sistema de locação", bg='#c9c9ff', fg='black', font=('Verdana 16 bold')) self.heading.pack(pady=0) # BOTOES CLIENTE ========================================================================= self.BotaoCadastrarCliente = Button(self.frame1, text="Cadastrar cliente", width=48, height=2, bg='#ffdfba', fg='black', font=('Verdana 15 bold'), command=self.cadastrar_cliente) self.BotaoCadastrarCliente.pack(fill=X, pady=0) self.BotaoAlterarCliente = Button(self.frame1, text="Alterar cliente", width=30, height=2, bg='#ffdfba', fg='black', font=('Verdana 15 bold'), command=self.altera_cliente) self.BotaoAlterarCliente.pack(fill=X, pady=0) self.BotaoExcluirCliente = Button(self.frame1, text="Excluir cliente", width=48, height=2, bg='#ffdfba', fg='black', font=('Verdana 15 bold'), command=self.deleta_cliente) self.BotaoExcluirCliente.pack(fill=X, pady=0) # BOTOES VEICULO ========================================================================= self.BotaoCadastrarVeiculo = Button(self.frame1, text="Cadastrar veiculo", width=48, height=2, bg='#c8a2c8', fg='black', font=('Verdana 15 bold'), command=self.cadastrar_veiculo) self.BotaoCadastrarVeiculo.pack(fill=X, pady=0) self.BotaoAlterarVeiculo = Button(self.frame1, text="Editar veiculo", width=48, height=2, bg='#c8a2c8', fg='black', font=('Verdana 15 bold'), command=self.altera_veiculo) self.BotaoAlterarVeiculo.pack(fill=X, pady=0) self.BotaoExcluirVeiculo = Button(self.frame1, text="Excluir veiculo", width=30, height=2, bg='#c8a2c8', fg='black', font=('Verdana 15 bold'), command=self.deletar_veiculo) self.BotaoExcluirVeiculo.pack(fill=X, pady=0) # BOTOES LOCACAO E SAIR ========================================================================= self.BotaoEfetuarLocacao = Button(self.frame2, text="Efetuar locação", width=30, height=9, bg='#baffc9', fg='black', font=('Verdana 15 bold'), command=self.efetuar_locacao) self.BotaoEfetuarLocacao.pack(fill=X, pady=0) self.BotaoDevolverVeiculo = Button(self.frame2, text="Devolver veiculo", width=30, height=9, bg='#baffc9', fg='black', font=('Verdana 15 bold'), command=self.devolve_veiculo) self.BotaoDevolverVeiculo.pack(fill=X, pady=0) self.BotaoSair = Button(self.frame1, text="Sair", width=22, height=2, bg='#ffb3ba', fg='black', font=('Verdana 15 bold'), command=self.close) self.BotaoSair.pack(fill=X, pady=0)
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI()
def __init__(self, parent): # 如果不是一个框架 Frame.__init__(self, parent) # 提供容器 self.pack(expand=YES, fill=BOTH) self.config(relief=RIDGE, border=2) # 重新配置
def __init__(self, name, *args, **kwargs): Frame.__init__(self, *args, **kwargs) self.TextData = Text(self) self.LabelData = Label(self) path_asli = '..\\Data Lagu\\asli\\reff' self.filepath_asli = [ os.path.join(path_asli, fname) for fname in os.listdir(path_asli) if fname.endswith('.wav') ] self.idx_tests = { '01': 0, '02': 1, '03': 2, '04': 3, '05': 4, '06': 5, '07': 6, '08': 7, '09': 8, '10': 9 } frInput = Frame(self) frInput.grid(row=0, column=0, padx=20, pady=10) lblJudulLagu = Label(frInput, text="Judul lagu") lblJudulLagu.grid(row=0, column=0, sticky="W", pady=10) lblTitik2 = Label(frInput, text=":") lblTitik2.grid(row=0, column=1) self.strJudulLagu = StringVar(value="") entJudulLagu = Entry(frInput, textvariable=self.strJudulLagu) entJudulLagu.grid(row=0, column=2) btnTripleDots = Button(frInput, text=". . .", command=self.fileDialog) btnTripleDots.grid(row=0, column=3, padx=10) lblParameter = Label(frInput, text="Parameter") lblParameter.grid(row=1, column=0, sticky="W") lblFilterBank = Label(frInput, text="Filter bank") lblFilterBank.grid(row=2, column=0, sticky="W") lblTitik2 = Label(frInput, text=":") lblTitik2.grid(row=2, column=1) self.strFilterBank = StringVar(value="20") entFilterBank = Entry(frInput, textvariable=self.strFilterBank) entFilterBank.grid(row=2, column=2) lblPFrame = Label(frInput, text="Panjang frame") lblPFrame.grid(row=3, column=0, sticky="W") lblTitik2 = Label(frInput, text=":") lblTitik2.grid(row=3, column=1) self.strPFrame = StringVar(value="0.5") entPFrame = Entry(frInput, textvariable=self.strPFrame) entPFrame.grid(row=3, column=2) lblOvFrame = Label(frInput, text="Overlapping frame") lblOvFrame.grid(row=4, column=0, sticky="W") lblTitik2 = Label(frInput, text=":") lblTitik2.grid(row=4, column=1) self.strOvFrame = StringVar(value="0.25") entOvFrame = Entry(frInput, textvariable=self.strOvFrame) entOvFrame.grid(row=4, column=2) btnReset = Button(frInput, text="RESET", width="10", command=self.reset) btnReset.grid(row=5, column=0, columnspan=2, padx=5, pady=10) btnCari = Button(frInput, text="CARI", width="10", command=self.identifikasi) btnCari.grid(row=5, column=2, pady=10) frHasil = Frame(self) frHasil.grid(row=1, column=0, padx=20, pady=10) lblHasilIdent = Label(frHasil, text="Hasil Identifikasi") lblHasilIdent.grid(row=0, column=0, columnspan=3, pady=10) self.hCover = StringVar(value="") entHasilCover = Entry(frHasil, textvariable=self.hCover) entHasilCover.grid(row=1, column=0, sticky="E") lblEqual = Label(frHasil, text="=") lblEqual.grid(row=1, column=1) self.hAsli = StringVar(value="") entHasilAsli = Entry(frHasil, textvariable=self.hAsli) entHasilAsli.grid(row=1, column=2) lblKesimpulan = Label(frHasil, text="Kesimpulan") lblKesimpulan.grid(row=2, column=0, sticky="W") lblEqual = Label(frHasil, text="=") lblEqual.grid(row=2, column=1) self.kesimpulan = StringVar(value="") entKesimpulan = Entry(frHasil, textvariable=self.kesimpulan) entKesimpulan.grid(row=2, column=2, padx=10, pady=5) self.lblWaktuProses = Label(frHasil, text="") self.lblWaktuProses.grid(row=3, column=0, columnspan=3, pady=10, padx=5) '''
def __init__(self, parent, controller): Frame.__init__(self, parent) load_file_butt = ttk.Button(self, text='Choose sdt file', command=lambda: self.load_file(controller)) load_file_butt.grid(row=1, column=1) ttk.Label( self, text="Gating start/end: (leave end at 0 for no gating)").grid( row=2, column=1) gate_start = ttk.Entry(self, textvariable=controller.start_gate) gate_start.grid(row=3, column=1) gate_end = ttk.Entry(self, textvariable=controller.end_gate) gate_end.grid(row=4, column=1) ttk.Label(self, text="Largest value cutoff? (um, leave at 0 for no cut off):" ).grid(row=3, column=2) cut_off_max = ttk.Entry(self, textvariable=controller.cut_off_max) cut_off_max.grid(row=4, column=2) IRF_check = ttk.Checkbutton(self, text="Automatically determine IRF?", variable=controller.IRF_var) IRF_check.grid(row=5, column=1) SBR_check = ttk.Checkbutton(self, text="Subtract back reflections?", variable=controller.SBR_var) SBR_check.grid(row=6, column=1) plot_butt = ttk.Button(self, text='Plot it', command=lambda: self.plot_it(controller)) plot_butt.grid(row=8, column=1, columnspan=2) fit_butt = ttk.Checkbutton(self, text='Fit instead of X-corr?', variable=controller.fit_var) fit_butt.grid(row=7, column=1) aspect_correct_toggle = ttk.Checkbutton( self, text='Correct aspect in graph? Input scene size (mm):', variable=controller.aspect_togg) aspect_correct_toggle.grid(row=1, column=2) scene_size = ttk.Entry(self, textvariable=controller.scene_size) scene_size.grid(row=2, column=2) remove_empty_pix_toggle = ttk.Checkbutton( self, text='Remove empty pixels from plots?', variable=controller.remove_empty_pix) remove_empty_pix_toggle.grid(row=5, column=2) binning_toggle = ttk.Checkbutton( self, text='Bin the data? Input bin factor:', variable=controller.bin_toggle) binning_toggle.grid(row=6, column=2) bin_factor = ttk.Entry(self, textvariable=controller.bin_factor) bin_factor.grid(row=7, column=2)
def __init__(self, parent, controller, background_col, foreground_col, font): """ Layout for the home screen """ Frame.__init__(self, parent, bg=background_col) self.controller = controller self.parent = parent self.picture_path = './/user_interface//home_screen_pic.png' self.logo = PhotoImage(file=self.resource_path(self.picture_path)) self.picture = Label(self, image=self.logo, borderwidth=0, highlightthickness=0) self.picture.image = self.logo self.description_label = Label( self, text= "This tool uses the SHA-256 algorithm to generate a target file's hash value.\n\nIt saves details of the hashed file to a .txt file in the same location and sets the target file to \nread-only.", bg=background_col, fg=foreground_col, font=font, justify='left') self.file_label = Label(self, text='Select file for hashing: ', bg=background_col, fg=foreground_col, font=font) self.file_entry = Entry(self, width=55) self.file_button = Button( self, text='Browse', width=6, command=lambda: self.controller.browse_file(self.file_entry)) self.hash_button = Button( self, text='Hash file', width=19, command=lambda: self.hash_file(self.file_entry.get())) self.hash_output_label = Label(self, text='Hash: ', bg=background_col, fg=foreground_col, font=font) self.copy_button = Button( self, text='Copy to clipboard', width=19, command=lambda: self.copy_to_clipboard(self.hashed_file)) self.picture.grid(row=0, column=0, sticky='W', padx=25, pady=5, columnspan=3) self.description_label.grid(row=2, column=0, sticky='W', padx=25, pady=15, columnspan=3) self.file_label.grid(row=3, column=0, sticky='W', padx=25, pady=20) self.file_entry.grid(row=3, column=1, sticky='E', padx=0, pady=0) self.file_button.grid(row=3, column=2, sticky='E', padx=0, pady=0) self.hash_button.grid(row=4, column=1, sticky='E', padx=0, pady=15) self.hash_output_label.grid(row=5, column=0, sticky='W', padx=25, pady=15, columnspan=3) self.copy_button.grid(row=6, column=1, sticky='E', padx=0, pady=15)
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() self.buatCheckButton()
def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.createWidgets()
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent #Окно программы self.initUI() #Функция запуска главного окна
def __init__(self, matchList=None, index=1): # matchList = [mode, {'path': path, 'topText': topText, 'bottomText': bottomText}, ...] self.matchList = matchList self.index = index if matchList == None: while True: # 加载对局记录 filename = input('filename: ') try: self.log = open('%s.txt' % filename, 'r').read().split('&') # 读取全部记录并分成单条 self.size = len(self.log) break except FileNotFoundError: print('%s is not found.' % filename) print('=' * 50) while True: # 选择模式 self.mode = int( input( 'enter 0 for original mode.\nenter 1 for YuzuSoft mode.\nmode: ' )) if self.mode in range(2): break else: print('wrong input.') else: self.match = self.matchList[index] self.log = open(self.match['path'], 'r').read().split('&') # 读取全部记录并分成单条 self.size = len(self.log) self.mode = self.matchList[0] topText = self.match[ 'topText'] if matchList and 'topText' in self.match else 'press any key to start' bottomText = self.match[ 'bottomText'] if matchList and 'bottomText' in self.match else 'by @SophieARG' print('=' * 50) declarations = self.log[0].split('\n') for declaration in declarations: if declaration != '' and declaration[0] != '*': print(declaration) # 打印说明信息 Frame.__init__(self) self.grid() self.master.title('UI for reviewing') self.master.bind("<Key>", self.press) self.gridCells = [] # 所有方格 background = Frame(self, bg=c.COLOR_BACKGROUND) # 背景 background.grid() bar = Frame(background, bg=c.COLOR_NONE, width=c.LENGTH * c.COLUMNS, height=c.LENGTH) # 顶端状态栏 bar.grid(row=0, column=0, columnspan=c.COLUMNS, padx=c.PADX, pady=c.PADY) info = Label(bar, text=topText, bg=c.COLOR_NONE, justify=CENTER, font=c.FONT, width=c.WORD_SIZE[0] * c.COLUMNS, height=c.WORD_SIZE[1]) info.grid() self.topInfo = info bar = Frame(background, bg=c.COLOR_NONE, width=c.LENGTH * c.COLUMNS, height=c.LENGTH) # 底端状态栏 bar.grid(row=c.ROWS + 1, column=0, columnspan=c.COLUMNS, padx=c.PADX, pady=c.PADY) info = Label(bar, text=bottomText, bg=c.COLOR_NONE, font=c.FONT, width=c.WORD_SIZE[0] * c.COLUMNS, height=c.WORD_SIZE[1]) info.grid() self.bottomInfo = info if self.mode == 0: # 2048原版 for row in range(1, c.ROWS + 1): gridRow = [] # 一行方格 for column in range(c.COLUMNS): cell = Frame(background, bg=c.COLOR_NONE, width=c.LENGTH, height=c.LENGTH) # 一个方格 cell.grid(row=row, column=column, padx=c.PADX, pady=c.PADY) number = Label(cell, text='', bg=c.COLOR_NONE, justify=CENTER, font=c.FONT, width=c.WORD_SIZE[0], height=c.WORD_SIZE[1]) number.grid() gridRow.append(number) self.gridCells.append(gridRow) if self.mode == 1: # 柚子社版 self.photos = { '+': [ PhotoImage(file='pic/%s_%d.png' % (c.PICTURES[0], _)) for _ in range(14) ], '-': [ PhotoImage(file='pic/%s_%d.png' % (c.PICTURES[1], _)) for _ in range(14) ] } photo = PhotoImage(file='pic/unknown.png') for row in range(1, c.ROWS + 1): gridRow = [] # 一行方格 for column in range(c.COLUMNS): cell = Frame(background) # 一个方格 cell.grid(row=row, column=column, padx=c.PADX, pady=c.PADY) number = Label(cell, image=photo) number.grid() gridRow.append(number) self.gridCells.append(gridRow) self.cur = 0 # 读取单条记录的游标 self.state = True # 游标运动的状态, True代表向前 self.mainloop()