ttk

Align tabs from right to left using ttk.Notebook widget

白昼怎懂夜的黑 提交于 2019-12-01 04:03:42
I want to align tabs (panes) inside a ttk.Notebook widget from right to left (the default is from left to right). How might this be done? Below is my current code: import Tkinter as tk import ttk root = tk.Tk() root.minsize(300, 300) root.geometry("1000x700") box = ttk.Notebook(root, width=1000, height=650) tab1 = tk.Frame(root) tab2 = tk.Frame(root) tab3 = tk.Frame(root) box.add(tab1, text="tab1") box.add(tab2, text="tab2") box.add(tab3, text="tab3") box.pack(side=tk.TOP) root.mainloop() There is actually a style option for this - tabposition . import tkinter as tk from tkinter import ttk

ttk.Combobox glitch when state is read-only and out of focus

隐身守侯 提交于 2019-12-01 03:06:07
问题 When a ttk.Combobox is read-only and not in focus, its text background gets white which differs from the gray field background and makes the combobox look ugly: The desired style would be the second one's. How to make a combobox work like that? 回答1: The solution is to change the ttk style like this: s = ttk.Style() s.map("TCombobox", selectbackground=[ ('!readonly', '!focus', 'SystemWindow'), ('readonly', '!focus', 'SystemButtonFace'), ], ) This changes the behavior of the comboboxes globally

How to do a screenshot of a tkinter application?

孤人 提交于 2019-12-01 00:58:21
I need to do a screenshot of the content of the tkinter application below. I am on Windows 7 (or 8). from Tkinter import * def test(x): #print "I'm in event:", x if x == 1: # if event on entry e1 print 'e1 event' # do some thing elif x == 2: # also if event on entry e2 print 'e2 event' # do some thing else else: print 'no event' def test1(x): test(1) def test2(x): test(2) root=Tk() root.minsize(500,500) e1=Entry(root) e1.pack() e2=Entry(root) e2.pack() e1.bind( "<FocusOut>", test1) e2.bind( "<FocusOut>", test2) button=Button(root, text='print').pack(side=BOTTOM) root.mainloop() PurityLake

How to get progressbar start() info from one window (class) to other?

[亡魂溺海] 提交于 2019-11-30 20:25:36
问题 There is a main window with menu and the progressbar. A correspondence window with OK button opens upon menu command and the OK button starts the process (here: 3 sec. sleep). The correspondence window is created via inheritance from a class I have not provided here (If required for answer, please let me know). The methods apply and ok override existing methods in the mother class. Now my problem: Since the progressbar sits in the main window (class App) and progressbar(start) and progressbar

How to change the color of ttk button

青春壹個敷衍的年華 提交于 2019-11-30 20:23:28
I am using Python 3.x on Windows. My problem is I want to customize a button widget of ttk by completely changing its background and foreground color. But so far, I have been unsuccessful. My desired button is: I read the ttk.Style guide and used their code: ttk.Style().configure("TButton", padding=6, relief="flat", background="#000") btn = ttk.Button(text="Sample") btn.pack() But it's changing the border color instead of the whole button bakground. Here is the output: Kindly help me achieve my desired button. Unfortunately, there isn't an easy way to change the foreground of a button from the

Why ttk Progressbar appears after process in Tkinter

若如初见. 提交于 2019-11-30 14:39:10
I want to create a large text upon Tkinter menu command and provide visual support by a progress bar. Although the progress bar is meant to start before the subsequent time-consuming loop, the progress bar shows up only after the large text was created and displayed. def menu_bar(self): self.create_menu.add_command(label="Create large file", command=self.create_large_file) def create_large_file(self): self.progressbar = ttk.Progressbar(self.master, mode='indeterminate') self.progressbar.pack() self.progressbar.start() self.text.delete(1.0, 'end') self.file_content = [] i = 0 while i < 2000000:

Changing the appearance of a Scrollbar in tkinter (using ttk styles)

假装没事ソ 提交于 2019-11-30 14:03:16
问题 I was wondering if you could help me with a style options issue in ttk. I've managed to change most of the basic ttk widgets to the style of my preference. I'm only stuck at changing the style of a scrollbar. I've searched for hours looking for an answer, unfortunately to no avail. Here's a sample code using the scrollbar style option: import tkinter as tk from tkinter import ttk class Gui: def __init__(self,mainframe): #set the style style = ttk.Style() style.configure('Horizontal.TScrollbar

Set a default value for a ttk Combobox

纵然是瞬间 提交于 2019-11-30 13:41:47
I'm using Python 3.2.1 in Arch Linux x86_64. This one is really driving me crazy: I just want to have a default, preselected value for a ttk.Combobox as soon as I grid it. This is my code: from tkinter import Tk, StringVar, ttk root = Tk() def combo(parent): value = StringVar() box = ttk.Combobox(parent, textvariable=value, state='readonly') box['values'] = ('A', 'B', 'C') box.current(0) box.grid(column=0, row=0) combo(root) root.mainloop() Which draws an empty Combobox . What's funny is that if I don't use a function it works perfectly: from tkinter import Tk, StringVar, ttk root = Tk() value

ttk Entry background colour

。_饼干妹妹 提交于 2019-11-30 13:29:22
How exactly do I change the background colour of an Entry widget from ttk? What I have so far is: self.estyle = ttk.Style() self.estyle.configure("EntryStyle.TEntry", background='black') self.estyle.map("EntryStyle.TEntry", foreground=[('disabled', 'yellow'), ('active', 'blue')], background=[('disabled', 'magenta'), ('active', 'green')], highlightcolor=[('focus', 'green'), ('!focus', 'red')]) self.urlentry_v = StringVar() self.urlentry = ttk.Entry(self.input_frame, style="EntryStyle.TEntry", textvariable=self.urlentry_v) Basically, I've changed everything I can think of, but the text entry

Python: Tkinter/ttk themed Message Box

隐身守侯 提交于 2019-11-30 13:11:39
I started making a GUI with Tkinter and I added the module tkMessageBox as well. But recently I discovered that importing the module ttk gives more 'up-to-date' results: buttons and texts boxes appear with the actual style of the current OS. This is: Windows 10 buttons are plain and blue-lighted, and not those shaded gray blocky buttons from previous versions. But unfortunately, I can't find a way to use this ttk themed widgets on the common Dialog Boxes (the ones which I imported from tkMessageBox ). So OK/Cancel dialogs (for instance) still appear with a theme that doesn't belongs to Windows