Python tkinter.W Examples
The following are 30
code examples of tkinter.W().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tkinter
, or try the search function
.
Example #1
Source File: annotation_gui.py From SEM with MIT License | 9 votes |
def preferences(self, event=None): preferenceTop = tkinter.Toplevel() preferenceTop.focus_set() notebook = ttk.Notebook(preferenceTop) frame1 = ttk.Frame(notebook) notebook.add(frame1, text='general') frame2 = ttk.Frame(notebook) notebook.add(frame2, text='shortcuts') c = ttk.Checkbutton(frame1, text="Match whole word when broadcasting annotation", variable=self._whole_word) c.pack() shortcuts_vars = [] shortcuts_gui = [] cur_row = 0 j = -1 frame_list = [] frame_list.append(ttk.LabelFrame(frame2, text="common shortcuts")) frame_list[-1].pack(fill="both", expand="yes") for i, shortcut in enumerate(self.shortcuts): j += 1 key, cmd, bindings = shortcut name, command = cmd shortcuts_vars.append(tkinter.StringVar(frame_list[-1], value=key)) tkinter.Label(frame_list[-1], text=name).grid(row=cur_row, column=0, sticky=tkinter.W) entry = tkinter.Entry(frame_list[-1], textvariable=shortcuts_vars[j]) entry.grid(row=cur_row, column=1) cur_row += 1 notebook.pack() # # ? menu methods #
Example #2
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 7 votes |
def create_statusbar(self): statusBar = ttk.Frame(self.master) statusLabel = ttk.Label(statusBar, textvariable=self.statusText) statusLabel.grid(column=0, row=0, sticky=(tk.W, tk.E)) self.modifiedLabel = ttk.Label(statusBar, relief=tk.SUNKEN, anchor=tk.CENTER) self.modifiedLabel.grid(column=1, row=0, pady=2, padx=1) TkUtil.Tooltip.Tooltip(self.modifiedLabel, text="MOD if the text has unsaved changes") self.positionLabel = ttk.Label(statusBar, relief=tk.SUNKEN, anchor=tk.CENTER) self.positionLabel.grid(column=2, row=0, sticky=(tk.W, tk.E), pady=2, padx=1) TkUtil.Tooltip.Tooltip(self.positionLabel, text="Current line and column position") ttk.Sizegrip(statusBar).grid(row=0, column=4, sticky=(tk.S, tk.E)) statusBar.columnconfigure(0, weight=1) statusBar.grid(row=2, column=0, columnspan=3, sticky=(tk.W, tk.E)) self.set_status_text("Start typing to create a new document or " "click File→Open")
Example #3
Source File: Find.py From python-in-practice with GNU General Public License v3.0 | 6 votes |
def create_layout(self): pad = dict(padx=PAD, pady=PAD) padWE = dict(sticky=(tk.W, tk.E), **pad) self.findLabel.grid(row=0, column=0, sticky=tk.W, **pad) self.findEntry.grid(row=0, column=1, **padWE) self.replaceLabel.grid(row=1, column=0, sticky=tk.W, **pad) self.replaceEntry.grid(row=1, column=1, **padWE) self.caseSensitiveCheckbutton.grid(row=2, column=0, columnspan=2, **padWE) self.wholeWordsCheckbutton.grid(row=3, column=0, columnspan=2, **padWE) self.findButton.grid(row=0, column=2, **padWE) self.replaceButton.grid(row=1, column=2, **padWE) self.closeButton.grid(row=2, column=2, **padWE) self.extendButton.grid(row=3, column=2, **padWE) self.grid_columnconfigure(1, weight=1) self.minsize(180, 90) self.maxsize(600, 150) self.geometry("+{}+{}".format(self.master.winfo_rootx() + 200, self.master.winfo_rooty() - 30))
Example #4
Source File: friendslist.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
def load_friends(self): my_friends = self.requester.get_friends(self.username) for user in my_friends["friends"]: if user['username'] != self.username: friend_frame = ttk.Frame(self.canvas_frame) friend_avatar_path = os.path.join(friend_avatars_dir, f"{user['username']}.png") if user["avatar"]: with open(friend_avatar_path, 'wb') as friend_avatar: img = base64.urlsafe_b64decode(user['avatar']) friend_avatar.write(img) else: friend_avatar_path = default_avatar_path profile_photo = tk.PhotoImage(file=friend_avatar_path) profile_photo_label = ttk.Label(friend_frame, image=profile_photo) profile_photo_label.image = profile_photo friend_name = ttk.Label(friend_frame, text=user['real_name'], anchor=tk.W) message_this_friend = partial(self.open_chat_window, username=user["username"], real_name=user["real_name"], avatar=friend_avatar_path) block_this_friend = partial(self.block_friend, username=user["username"]) message_button = ttk.Button(friend_frame, text="Chat", command=message_this_friend) block_button = ttk.Button(friend_frame, text="Block", command=block_this_friend) profile_photo_label.pack(side=tk.LEFT) friend_name.pack(side=tk.LEFT) message_button.pack(side=tk.RIGHT) block_button.pack(side=tk.RIGHT, padx=(0, 30)) friend_frame.pack(fill=tk.X, expand=1)
Example #5
Source File: Find.py From python-in-practice with GNU General Public License v3.0 | 6 votes |
def create_layout(self): pad = dict(padx=PAD, pady=PAD) padWE = dict(sticky=(tk.W, tk.E), **pad) self.findLabel.grid(row=0, column=0, sticky=tk.W, **pad) self.findEntry.grid(row=0, column=1, **padWE) self.replaceLabel.grid(row=1, column=0, sticky=tk.W, **pad) self.replaceEntry.grid(row=1, column=1, **padWE) self.caseSensitiveCheckbutton.grid(row=2, column=0, columnspan=2, **padWE) self.wholeWordsCheckbutton.grid(row=3, column=0, columnspan=2, **padWE) self.findButton.grid(row=0, column=2, **padWE) self.replaceButton.grid(row=1, column=2, **padWE) self.closeButton.grid(row=2, column=2, **padWE) self.extendButton.grid(row=3, column=2, **padWE) self.grid_columnconfigure(1, weight=1) self.minsize(180, 90) self.maxsize(600, 150) self.geometry("+{}+{}".format(self.master.winfo_rootx() + 200, self.master.winfo_rooty() - 30))
Example #6
Source File: friendslist.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
def load_friends(self): friend_frame = ttk.Frame(self.canvas_frame) profile_photo = tk.PhotoImage(file="images/avatar.png") profile_photo_label = ttk.Label(friend_frame, image=profile_photo) profile_photo_label.image = profile_photo friend_name = ttk.Label(friend_frame, text="Jaden Corebyn", anchor=tk.W) message_button = ttk.Button(friend_frame, text="Chat", command=self.open_chat_window) profile_photo_label.pack(side=tk.LEFT) friend_name.pack(side=tk.LEFT) message_button.pack(side=tk.RIGHT) friend_frame.pack(fill=tk.X, expand=1)
Example #7
Source File: friendslist.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
def load_friends(self): all_users = self.requester.get_all_users() for user in all_users: if user['username'] != self.username: friend_frame = ttk.Frame(self.canvas_frame) profile_photo = tk.PhotoImage(file="images/avatar.png") profile_photo_label = ttk.Label(friend_frame, image=profile_photo) profile_photo_label.image = profile_photo friend_name = ttk.Label(friend_frame, text=user['real_name'], anchor=tk.W) message_this_friend = partial(self.open_chat_window, username=user["username"], real_name=user["real_name"]) message_button = ttk.Button(friend_frame, text="Chat", command=message_this_friend) profile_photo_label.pack(side=tk.LEFT) friend_name.pack(side=tk.LEFT) message_button.pack(side=tk.RIGHT) friend_frame.pack(fill=tk.X, expand=1)
Example #8
Source File: data_entry_app.py From Python-GUI-Programming-with-Tkinter with MIT License | 6 votes |
def __init__(self, parent, label='', input_class=ttk.Entry, input_var=None, input_args=None, label_args=None, **kwargs): super().__init__(parent, **kwargs) input_args = input_args or {} label_args = label_args or {} self.variable = input_var if input_class in (ttk.Checkbutton, ttk.Button, ttk.Radiobutton): input_args["text"] = label input_args["variable"] = input_var else: self.label = ttk.Label(self, text=label, **label_args) self.label.grid(row=0, column=0, sticky=(tk.W + tk.E)) input_args["textvariable"] = input_var self.input = input_class(self, **input_args) self.input.grid(row=1, column=0, sticky=(tk.W + tk.E)) self.columnconfigure(0, weight=1) self.error = getattr(self.input, 'error', tk.StringVar()) self.error_label = ttk.Label(self, textvariable=self.error) self.error_label.grid(row=2, column=0, sticky=(tk.W + tk.E))
Example #9
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 6 votes |
def create_statusbar(self): statusBar = ttk.Frame(self.master) statusLabel = ttk.Label(statusBar, textvariable=self.statusText) statusLabel.grid(column=0, row=0, sticky=(tk.W, tk.E)) self.modifiedLabel = ttk.Label(statusBar, relief=tk.SUNKEN, anchor=tk.CENTER) self.modifiedLabel.grid(column=1, row=0, pady=2, padx=1) TkUtil.Tooltip.Tooltip(self.modifiedLabel, text="MOD if the text has unsaved changes") self.positionLabel = ttk.Label(statusBar, relief=tk.SUNKEN, anchor=tk.CENTER) self.positionLabel.grid(column=2, row=0, sticky=(tk.W, tk.E), pady=2, padx=1) TkUtil.Tooltip.Tooltip(self.positionLabel, text="Current line and column position") ttk.Sizegrip(statusBar).grid(row=0, column=4, sticky=(tk.S, tk.E)) statusBar.columnconfigure(0, weight=1) statusBar.grid(row=2, column=0, columnspan=3, sticky=(tk.W, tk.E)) self.set_status_text("Start typing to create a new document or " "click File→Open")
Example #10
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 6 votes |
def layout_widgets(self): pad = dict(padx=PAD, pady=PAD) padWE = dict(sticky=(tk.W, tk.E), **pad) self.sourceLabel.grid(row=0, column=0, sticky=tk.W, **pad) self.sourceEntry.grid(row=0, column=1, columnspan=3, **padWE) self.sourceButton.grid(row=0, column=4, **pad) self.targetLabel.grid(row=1, column=0, sticky=tk.W, **pad) self.targetEntry.grid(row=1, column=1, columnspan=3, **padWE) self.targetButton.grid(row=1, column=4, **pad) self.dimensionLabel.grid(row=2, column=0, sticky=tk.W, **pad) self.dimensionCombobox.grid(row=2, column=1, **padWE) self.helpButton.grid(row=2, column=3, **pad) self.scaleButton.grid(row=2, column=4, **pad) self.aboutButton.grid(row=3, column=3, **pad) self.quitButton.grid(row=3, column=4, **pad) self.statusLabel.grid(row=3, column=0, columnspan=3, **padWE) self.grid()
Example #11
Source File: cameraConfig.py From crappy with GNU General Public License v2.0 | 6 votes |
def create_window(self): self.root.grid_rowconfigure(1,weight=1) self.root.grid_columnconfigure(0,weight=1) self.img_label = tk.Label(self.root) self.img_label.configure(image=self.c_img) self.hist_label = tk.Label(self.root) self.hist_label.grid(row=0,column=0) #self.img_label.pack(fill=tk.BOTH) self.img_label.grid(row=1,column=0, rowspan=len(self.camera.settings_dict)+2, sticky=tk.N+tk.E+tk.S+tk.W) self.create_inputs() self.create_infos() self.img_label.bind('<Motion>', self.update_reticle) self.img_label.bind('<4>', self.zoom_in) self.img_label.bind('<5>', self.zoom_out) self.root.bind('<MouseWheel>', self.zoom) self.img_label.bind('<1>', self.start_move) self.img_label.bind('<B1-Motion>', self.move)
Example #12
Source File: data_entry_app.py From Python-GUI-Programming-with-Tkinter with MIT License | 6 votes |
def __init__(self, parent, label='', input_class=ttk.Entry, input_var=None, input_args=None, label_args=None, **kwargs): super().__init__(parent, **kwargs) input_args = input_args or {} label_args = label_args or {} self.variable = input_var if input_class in (ttk.Checkbutton, ttk.Button, ttk.Radiobutton): input_args["text"] = label input_args["variable"] = input_var else: self.label = ttk.Label(self, text=label, **label_args) self.label.grid(row=0, column=0, sticky=(tk.W + tk.E)) input_args["textvariable"] = input_var self.input = input_class(self, **input_args) self.input.grid(row=1, column=0, sticky=(tk.W + tk.E)) self.columnconfigure(0, weight=1)
Example #13
Source File: data_entry_app.py From Python-GUI-Programming-with-Tkinter with MIT License | 6 votes |
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.title("ABQ Data Entry Application") self.resizable(width=False, height=False) ttk.Label( self, text="ABQ Data Entry Application", font=("TkDefaultFont", 16) ).grid(row=0) self.recordform = DataRecordForm(self) self.recordform.grid(row=1, padx=10) self.savebutton = ttk.Button(self, text="Save", command=self.on_save) self.savebutton.grid(sticky=tk.E, row=2, padx=10) # status bar self.status = tk.StringVar() self.statusbar = ttk.Label(self, textvariable=self.status) self.statusbar.grid(sticky=(tk.W + tk.E), row=3, padx=10) self.records_saved = 0
Example #14
Source File: better_hello_tkinter.py From Python-GUI-Programming-with-Tkinter with MIT License | 6 votes |
def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.name = tk.StringVar() self.hello_string = tk.StringVar() self.hello_string.set("Hello World") name_label = ttk.Label(self, text="Name:") name_entry = ttk.Entry(self, textvariable=self.name) ch_button = ttk.Button(self, text="Change", command=self.on_change) hello_label = ttk.Label(self, textvariable=self.hello_string, font=("TkDefaultFont", 64), wraplength=600) # Layout form name_label.grid(row=0, column=0, sticky=tk.W) name_entry.grid(row=0, column=1, sticky=(tk.W + tk.E)) ch_button.grid(row=0, column=2, sticky=tk.E) hello_label.grid(row=1, column=0, columnspan=3) self.columnconfigure(1, weight=1)
Example #15
Source File: view.py From ms_deisotope with Apache License 2.0 | 6 votes |
def configure_canvas(self): self.figure = Figure(dpi=100) self.canvas = FigureCanvasTkAgg(self.figure, master=self) self.axis = self.figure.add_subplot(111) self.canvas.draw() canvas_widget = self.canvas.get_tk_widget() canvas_widget.grid(row=0, column=0, sticky=tk.N + tk.W + tk.E + tk.S) self.canvas_cursor = Cursor(self.axis, tk.StringVar(master=self.root)) self.canvas.mpl_connect('motion_notify_event', self.canvas_cursor.mouse_move) self.span = SpanSelector( self.axis, self.zoom, 'horizontal', useblit=True, rectprops=dict(alpha=0.5, facecolor='red')) self.mz_span = None self.scan = None self.annotations = [] self.canvas.draw()
Example #16
Source File: view.py From ms_deisotope with Apache License 2.0 | 6 votes |
def configure_treeview(self): self.treeview = ttk.Treeview(self) self.treeview['columns'] = ["id", "time", 'ms_level', 'precursor_mz', 'precursor_charge', 'activation'] self.treeview.grid(row=2, column=0, sticky=tk.S + tk.W + tk.E + tk.N) self.treeview_scrollbar = ttk.Scrollbar(self, orient="vertical", command=self.treeview.yview) self.treeview_scrollbar.grid(row=2, column=0, sticky=tk.S + tk.E + tk.N) self.treeview.configure(yscrollcommand=self.treeview_scrollbar.set) self.treeview.heading('id', text="Scan ID") self.treeview.heading('#0', text='Index') self.treeview.heading("time", text='Time (min)') self.treeview.heading("ms_level", text='MS Level') self.treeview.heading("precursor_mz", text='Precursor M/Z') self.treeview.heading("precursor_charge", text='Precursor Z') self.treeview.heading("activation", text='Activation') self.treeview.column("#0", width=75) self.treeview.column("ms_level", width=75) self.treeview.column("time", width=75) self.treeview.column("precursor_mz", width=100) self.treeview.column("precursor_charge", width=100) self.treeview.bind("<<TreeviewSelect>>", self.on_row_click)
Example #17
Source File: statusbar.py From vy with MIT License | 6 votes |
def __init__(self, master): Frame.__init__(self, master) self.config(border=1) self.msg = Label(self, bd=1, relief=SUNKEN, anchor=W) self.msg.pack(side='left', expand=True, fill=X) self.column = Label(self, bd=1, relief=SUNKEN, anchor=W) self.column.config(text='Col: 0') self.column.pack(side='right', fill=X) self.line = Label(self, bd=1, relief=SUNKEN, anchor=W) self.line.config(text='Line: 1') self.line.pack(side='right', fill=X) self.mode = Label(self, bd=1, relief=SUNKEN, anchor=W) self.mode.config(text='Mode: 1') self.mode.pack(side='right', fill=X)
Example #18
Source File: SafeFrame.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def __init__(self, parent, isRunning): super().__init__(parent) self.parent = parent self.pack() self.state = DayState() self.isRunning = isRunning self.textClock = tkinter.Label(self, width=60, text="现在时间是00:00", anchor=tkinter.W) self.textScreen = ScrolledText(self, height=10, width=60, state="disable") self.buttonUse = tkinter.Button(self, text="使用金库") self.buttonAlarm = tkinter.Button(self, text="按下警铃") self.buttonPhone = tkinter.Button(self, text="正常通话") self.buttonExit = tkinter.Button(self, text="结束", command=self.quit) self.textClock.grid(row=0, columnspan=6, padx=2, pady=2, sticky=tkinter.EW) self.textScreen.grid(row=1, columnspan=6, padx=2, pady=2, sticky=tkinter.EW) self.buttonUse.grid(row=2, column=1, padx=2, pady=2, sticky=tkinter.EW) self.buttonAlarm.grid(row=2, column=2, padx=2, pady=2, sticky=tkinter.EW) self.buttonPhone.grid(row=2, column=3, padx=2, pady=2, sticky=tkinter.EW) self.buttonExit.grid(row=2, column=4, padx=2, pady=2, sticky=tkinter.EW) self.buttonUse.bind("<Button-1>", self.useEvent) self.buttonAlarm.bind("<Button-1>", self.useAlarm) self.buttonPhone.bind("<Button-1>", self.usePhone)
Example #19
Source File: LoginFrame.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def __init__(self, parent): super().__init__(parent) self.parent = parent self.pack() self.checkValue = tkinter.StringVar() self.createColleagues() self.checkGuest.grid(row=0, column=0, padx=2, pady=2, sticky=tkinter.W) self.checkLogin.grid(row=0, column=1, padx=2, pady=2, sticky=tkinter.EW) self.usernameLabel.grid(row=1, column=0, padx=2, pady=2, sticky=tkinter.W) self.textUser.grid(row=1, column=1, padx=2, pady=2, sticky=tkinter.EW) self.passwordLabel.grid(row=2, column=0, padx=2, pady=2, sticky=tkinter.W) self.textPassword.grid(row=2, column=1, padx=2, pady=2, sticky=tkinter.EW) self.buttonOk.grid(row=3, column=0, padx=2, pady=2, sticky=tkinter.EW) self.buttonCancel.grid(row=3, column=1, padx=2, pady=2, sticky=tkinter.EW) self.checkGuest.focus_set() self.checkGuest.bind("<Button-1>", self.colleagueChanged) self.checkLogin.bind("<Button-1>", self.colleagueChanged) self.textUser.bind("<Key>", self.colleagueChanged) self.textPassword.bind("<Key>", self.colleagueChanged)
Example #20
Source File: widgets.py From Python-GUI-Programming-with-Tkinter with MIT License | 5 votes |
def grid(self, sticky=(tk.E + tk.W), **kwargs): super().grid(sticky=sticky, **kwargs)
Example #21
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
def create_central_area(self): self.editor = Editor.Editor(self.master, set_status_text=self.set_status_text, font=self.create_font(), maxundo=0, undo=True, wrap=tk.WORD) self.editor.grid(row=1, column=1, sticky=(tk.N, tk.S, tk.W, tk.E), padx=PAD, pady=PAD) self.editor.text.bind("<<Selection>>", self.on_selection) self.editor.text.bind("<<Modified>>", self.on_modified) self.editor.text.bind("<KeyRelease>", self.on_moved, "+") self.editor.text.bind("<ButtonRelease>", self.on_moved, "+") self.editor.text.focus()
Example #22
Source File: widgets.py From Python-GUI-Programming-with-Tkinter with MIT License | 5 votes |
def __init__(self, parent, label='', input_class=None, input_var=None, input_args=None, label_args=None, field_spec=None, **kwargs): super().__init__(parent, **kwargs) input_args = input_args or {} label_args = label_args or {} if field_spec: field_type = field_spec.get('type', FT.string) input_class = input_class or self.field_types.get(field_type)[0] var_type = self.field_types.get(field_type)[1] self.variable = input_var if input_var else var_type() # min, max, increment if 'min' in field_spec and 'from_' not in input_args: input_args['from_'] = field_spec.get('min') if 'max' in field_spec and 'to' not in input_args: input_args['to'] = field_spec.get('max') if 'inc' in field_spec and 'increment' not in input_args: input_args['increment'] = field_spec.get('inc') # values if 'values' in field_spec and 'values' not in input_args: input_args['values'] = field_spec.get('values') else: self.variable = input_var if input_class in (ttk.Checkbutton, ttk.Button, ttk.Radiobutton): input_args["text"] = label input_args["variable"] = self.variable else: self.label = ttk.Label(self, text=label, **label_args) self.label.grid(row=0, column=0, sticky=(tk.W + tk.E)) input_args["textvariable"] = self.variable self.input = input_class(self, **input_args) self.input.grid(row=1, column=0, sticky=(tk.W + tk.E)) self.columnconfigure(0, weight=1) self.error = getattr(self.input, 'error', tk.StringVar()) self.error_label = ttk.Label(self, textvariable=self.error) self.error_label.grid(row=2, column=0, sticky=(tk.W + tk.E))
Example #23
Source File: widgets.py From Python-GUI-Programming-with-Tkinter with MIT License | 5 votes |
def __init__(self, parent, label='', input_class=None, input_var=None, input_args=None, label_args=None, field_spec=None, **kwargs): super().__init__(parent, **kwargs) input_args = input_args or {} label_args = label_args or {} if field_spec: field_type = field_spec.get('type', FT.string) input_class = input_class or self.field_types.get(field_type)[0] var_type = self.field_types.get(field_type)[1] self.variable = input_var if input_var else var_type() # min, max, increment if 'min' in field_spec and 'from_' not in input_args: input_args['from_'] = field_spec.get('min') if 'max' in field_spec and 'to' not in input_args: input_args['to'] = field_spec.get('max') if 'inc' in field_spec and 'increment' not in input_args: input_args['increment'] = field_spec.get('inc') # values if 'values' in field_spec and 'values' not in input_args: input_args['values'] = field_spec.get('values') else: self.variable = input_var if input_class in (ttk.Checkbutton, ttk.Button, ttk.Radiobutton): input_args["text"] = label input_args["variable"] = self.variable else: self.label = ttk.Label(self, text=label, **label_args) self.label.grid(row=0, column=0, sticky=(tk.W + tk.E)) input_args["textvariable"] = self.variable self.input = input_class(self, **input_args) self.input.grid(row=1, column=0, sticky=(tk.W + tk.E)) self.columnconfigure(0, weight=1) self.error = getattr(self.input, 'error', tk.StringVar()) self.error_label = ttk.Label(self, textvariable=self.error, **label_args) self.error_label.grid(row=2, column=0, sticky=(tk.W + tk.E))
Example #24
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
def create_layout(self): padWE = dict(sticky=(tk.W, tk.E), padx="0.5m", pady="0.5m") self.currencyFromCombobox.grid(row=0, column=0, **padWE) self.amountSpinbox.grid(row=0, column=1, **padWE) self.currencyToCombobox.grid(row=1, column=0, **padWE) self.resultLabel.grid(row=1, column=1, **padWE) self.grid(row=0, column=0, sticky=(tk.N, tk.S, tk.E, tk.W)) self.columnconfigure(0, weight=2) self.columnconfigure(1, weight=1) self.master.columnconfigure(0, weight=1) self.master.rowconfigure(0, weight=1) self.master.minsize(150, 40)
Example #25
Source File: widgets.py From Python-GUI-Programming-with-Tkinter with MIT License | 5 votes |
def __init__(self, parent, label='', input_class=None, input_var=None, input_args=None, label_args=None, field_spec=None, **kwargs): super().__init__(parent, **kwargs) input_args = input_args or {} label_args = label_args or {} if field_spec: field_type = field_spec.get('type', FT.string) input_class = input_class or self.field_types.get(field_type)[0] var_type = self.field_types.get(field_type)[1] self.variable = input_var if input_var else var_type() # min, max, increment if 'min' in field_spec and 'from_' not in input_args: input_args['from_'] = field_spec.get('min') if 'max' in field_spec and 'to' not in input_args: input_args['to'] = field_spec.get('max') if 'inc' in field_spec and 'increment' not in input_args: input_args['increment'] = field_spec.get('inc') # values if 'values' in field_spec and 'values' not in input_args: input_args['values'] = field_spec.get('values') else: self.variable = input_var if input_class in (ttk.Checkbutton, ttk.Button, ttk.Radiobutton): input_args["text"] = label input_args["variable"] = self.variable else: self.label = ttk.Label(self, text=label, **label_args) self.label.grid(row=0, column=0, sticky=(tk.W + tk.E)) input_args["textvariable"] = self.variable self.input = input_class(self, **input_args) self.input.grid(row=1, column=0, sticky=(tk.W + tk.E)) self.columnconfigure(0, weight=1) self.error = getattr(self.input, 'error', tk.StringVar()) self.error_label = ttk.Label(self, textvariable=self.error, **label_args) self.error_label.grid(row=2, column=0, sticky=(tk.W + tk.E))
Example #26
Source File: widgets.py From Python-GUI-Programming-with-Tkinter with MIT License | 5 votes |
def grid(self, sticky=(tk.E + tk.W), **kwargs): super().grid(sticky=sticky, **kwargs)
Example #27
Source File: better_hello_tkinter.py From Python-GUI-Programming-with-Tkinter with MIT License | 5 votes |
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # set the window properties self.title("Hello Tkinter") self.geometry("800x600") self.resizable(width=False, height=False) # Define the UI HelloView(self).grid(sticky=(tk.E + tk.W + tk.N + tk.S)) self.columnconfigure(0, weight=1)
Example #28
Source File: widgets.py From Python-GUI-Programming-with-Tkinter with MIT License | 5 votes |
def grid(self, sticky=(tk.E + tk.W), **kwargs): super().grid(sticky=sticky, **kwargs)
Example #29
Source File: widgets.py From Python-GUI-Programming-with-Tkinter with MIT License | 5 votes |
def grid(self, sticky=(tk.E + tk.W), **kwargs): super().grid(sticky=sticky, **kwargs)
Example #30
Source File: widgets.py From Python-GUI-Programming-with-Tkinter with MIT License | 5 votes |
def __init__(self, parent, label='', input_class=None, input_var=None, input_args=None, label_args=None, field_spec=None, **kwargs): super().__init__(parent, **kwargs) input_args = input_args or {} label_args = label_args or {} if field_spec: field_type = field_spec.get('type', FT.string) input_class = input_class or self.field_types.get(field_type)[0] var_type = self.field_types.get(field_type)[1] self.variable = input_var if input_var else var_type() # min, max, increment if 'min' in field_spec and 'from_' not in input_args: input_args['from_'] = field_spec.get('min') if 'max' in field_spec and 'to' not in input_args: input_args['to'] = field_spec.get('max') if 'inc' in field_spec and 'increment' not in input_args: input_args['increment'] = field_spec.get('inc') # values if 'values' in field_spec and 'values' not in input_args: input_args['values'] = field_spec.get('values') else: self.variable = input_var if input_class in (ttk.Checkbutton, ttk.Button, ttk.Radiobutton): input_args["text"] = label input_args["variable"] = self.variable else: self.label = ttk.Label(self, text=label, **label_args) self.label.grid(row=0, column=0, sticky=(tk.W + tk.E)) input_args["textvariable"] = self.variable self.input = input_class(self, **input_args) self.input.grid(row=1, column=0, sticky=(tk.W + tk.E)) self.columnconfigure(0, weight=1) self.error = getattr(self.input, 'error', tk.StringVar()) self.error_label = ttk.Label(self, textvariable=self.error) self.error_label.grid(row=2, column=0, sticky=(tk.W + tk.E))