本文整理汇总了Python中tkinter.ttk.Style.theme_use方法的典型用法代码示例。如果您正苦于以下问题:Python Style.theme_use方法的具体用法?Python Style.theme_use怎么用?Python Style.theme_use使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Style
的用法示例。
在下文中一共展示了Style.theme_use方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import theme_use [as 别名]
def __init__(self, title="", message="", button="Ok", image=None,
checkmessage="", style="clam", **options):
"""
Create a messagebox with one button and a checkbox below the button:
parent: parent of the toplevel window
title: message box title
message: message box text
button: message displayed on the button
image: image displayed at the left of the message
checkmessage: message displayed next to the checkbox
**options: other options to pass to the Toplevel.__init__ method
"""
Tk.__init__(self, **options)
self.resizable(False, False)
self.title(title)
s = Style(self)
s.theme_use(style)
if image:
Label(self, text=message, wraplength=335,
font="Sans 11", compound="left",
image=image).grid(row=0, padx=10, pady=(10, 0))
else:
Label(self, text=message, wraplength=335,
font="Sans 11").grid(row=0, padx=10, pady=(10, 0))
b = Button(self, text=button, command=self.destroy)
b.grid(row=2, padx=10, pady=10)
self.var = BooleanVar(self)
c = Checkbutton(self, text=checkmessage, variable=self.var)
c.grid(row=1, padx=10, pady=0, sticky="e")
self.grab_set()
b.focus_set()
self.wait_window(self)
示例2: MainWindow
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import theme_use [as 别名]
class MainWindow(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.grid()
self.init_ui()
self.wallhandler = WallHandler()
self.reddit = Reddit()
def init_ui(self):
self.parent.title("Papers")
self.style = Style()
self.style.theme_use("clam")
frame = Frame(self, relief=RAISED, borderwidth=1)
frame.grid(row=0, column=0)
label = Label(frame, text="Change Wallpaper")
label.grid(row=0, column=0)
button = Button(frame, text="Change", command=self.change)
button.grid(row=1, column=0)
label = Label(frame, text="Fetch Wallpapers")
label.grid(row=2, column=0)
button = Button(frame, text="Fetch", command=self.fetch)
button.grid(row=3, column=0)
def change(self):
self.wallhandler.run()
def fetch(self):
self.reddit.run()
示例3: __init__
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import theme_use [as 别名]
class About:
def __init__(self, parent):
self.parent = parent
self.style = Style()
self.style.theme_use('clam')
self.root = Toplevel()
self.root.title('pyEdit - About')
self.root.resizable(False, False)
self.root.minsize(200, 50)
self.root.columnconfigure(0, weight=1)
self.root.bind('<Expose>', lambda e: Utils.on_expose(self))
self.root.wm_protocol('WM_DELETE_WINDOW', lambda: Utils.on_close(self))
self.label_app_name = Label(self.root, text='pyEdit (Lightweight IDE)')
self.label_app_name.grid(column=0, row=0, sticky='nsew', ipadx=5, ipady=5)
self.label_author = Label(self.root, text='Author: Marek Kouřil')
self.label_author.grid(column=0, row=1, sticky='nsew', ipadx=5, ipady=5)
self.label_year = Label(self.root, text='2016')
self.label_year.grid(column=0, row=2, sticky='nsew', ipadx=5, ipady=5)
self.label_course = Label(self.root, text='\'URO\' course')
self.label_course.grid(column=0, row=3, sticky='nsew', ipadx=5, ipady=5)
示例4: MainWindow
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import theme_use [as 别名]
class MainWindow(Frame):
"""
Macro class for the main program window
"""
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.parent.title('PyNBTx %s' % __version__)
self.style = Style()
self.style.theme_use('default')
self.style.configure('TButton', padding=0)
self.pack(fill=BOTH, expand=1)
self.menu = MainMenu(root)
self.toolbar = ToolBar(self)
self.tree = Treeview(self, height=20)
self.tree_display = TreeDisplay(self.tree)
self.ui_init()
def ui_init(self):
root['menu'] = self.menu
self.toolbar.pack(anchor=NW, padx=4, pady=4)
self.tree.column('#0', width=300)
self.tree.pack(fill=BOTH, anchor=NW, padx=4, pady=4)
示例5: Main
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import theme_use [as 别名]
class Main(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.info = {}
self.window = None
self.size = (640, 480)
self.fields = []
self.init_ui()
def init_ui(self):
self.parent.title("Node Writer")
self.style = Style()
self.style.theme_use("alt")
self.pack(fill="both", expand=True)
menubar = Menu(self.parent)
self.parent.config(menu=menubar)
menubar.add_command(label="New", command=self.onNew)
menubar.add_command(label="Show Info", command=self.get_info)
menubar.add_command(label="Exit", command=self.quit)
self.canvas = Canvas(self, background="white", width=self.size[0], height=self.size[1])
self.canvas.pack(fill="both", expand=1)
self.canvas.bind("<Motion>", self.move_boxes)
def move_boxes(self, event):
print(event.x, event.y)
"""
x, y = (event.x-1, event.y-1)
x1, y1, x2, y2 = self.canvas.bbox("test")
if x > x1 and y > y1 and x < x2 and y < y2:
print("Hit")
else:
print("Missed")
"""
def onNew(self):
new = Node(self, "Node_entry")
label = new.insert_entry_field("Labels")
label2 = new.insert_entry_field("Labels2")
text = new.insert_text_field("Text")
new.ok_cancel_buttons()
def get_info(self):
x, y = (self.size[0]/2, self.size[1]/2)
for i in self.info:
label_frame= LabelFrame(self, text="name")
label_frame.pack(fill="y")
for entry in self.info[i]["Entry"]:
frame = Frame(label_frame)
frame.pack(fill="x")
label = Label(label_frame, text=self.info[i]["Entry"][entry], width=6)
label.pack(side="left", anchor="n", padx=5, pady=5)
for text in self.info[i]["Text"]:
frame = Frame(label_frame)
frame.pack(fill="x")
label = Label(label_frame, text=self.info[i]["Text"][text], width=6)
label.pack(side="left", anchor="n", padx=5, pady=5)
window = self.canvas.create_window(x, y, window=label_frame, tag="test")
示例6: create_frame
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import theme_use [as 别名]
def create_frame(self):
frame_style = Style()
frame_style.theme_use('alt')
frame_style.configure("TFrame",
relief='raised')
self.frame = Frame(self.window, style="frame_style.TFrame")
self.frame.rowconfigure(1)
self.frame.columnconfigure(1)
self.frame.grid(row=0, column=0)
示例7: poly_pocket
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import theme_use [as 别名]
class poly_pocket(Frame):
def __init__(self):
window = Tk()
self.parent = window
window.geometry("800x600+50+50")
Frame.__init__(self, window)
self.baseline = 0
self.initUI()
window.mainloop()
def initUI(self):
# Initialize and name Window
self.parent.title("Poly Pocket")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
def new_baseline():
return
def old_baseline():
return
def test(baseline):
return
def spark_connect():
return
def leap_connect():
return
def quit():
self.parent.destroy()
return
welcome = "Welcome to Poly Pocket!"
welcome_label = Label(self, text=welcome, font=("Helvetica", 24))
welcome_label.place(x=5, y=5)
welcome_label.pack()
baseline_button = Button(self, text="New Baseline",
command=new_baseline())
recover_baseline_button = Button(self, text="Recover Baseline",
command=old_baseline())
test_button = Button(self, text="Conduct Test",
command=test(self.baseline))
connect_leap_button = Button(self, text="Establish Leap Connection",
command=leap_connect)
connect_spark_button = Button(self, text="Establish Spark Connection",
command=spark_connect)
exit_button = Button(self, text="Quit",
command=quit)
baseline_button.place(relx=0.5, rely=0.3, anchor=CENTER)
recover_baseline_button.place(relx=0.5, rely=0.4, anchor=CENTER)
test_button.place(relx=0.5, rely=0.5, anchor=CENTER)
connect_leap_button.place(relx=0.5, rely=0.6, anchor=CENTER)
connect_spark_button.place(relx=0.5, rely=0.7, anchor=CENTER)
exit_button.place(relx=0.5, rely = 0.8, anchor=CENTER)
示例8: __init__
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import theme_use [as 别名]
class Help:
def __init__(self, parent):
self.parent = parent
self.style = Style()
self.style.theme_use('clam')
self.root = Toplevel()
self.root.title('pyEdit - Help')
self.root.resizable(False, False)
self.root.minsize(200, 50)
self.root.columnconfigure(0, weight=1)
self.root.rowconfigure(0, weight=1)
self.root.bind('<Expose>', lambda e: Utils.on_expose(self))
self.root.wm_protocol('WM_DELETE_WINDOW', lambda: Utils.on_close(self))
self.text = self.get_content()
self.font = font.Font(family='Monospace', size=10, weight='normal')
self.font_spacing = None
self.font_spacing = self.font.metrics('descent')
self.text_widget = Text(self.root,
relief='flat',
bd=0,
font=self.font)
self.text_widget.grid(column=0, row=0, sticky='nsew')
self.text_widget.delete('1.0', 'end')
self.text_widget.insert('1.0', self.text)
self.text_widget.config(state='disabled')
self.scrollbar = Scrollbar(self.root, bd=0, orient='vertical', command=self.text_widget.yview)
self.scrollbar.grid(column=1, row=0, sticky='nsew')
self.text_widget.config(yscrollcommand=self.scrollbar.set)
def get_content(self):
text = ''
try:
file = open(self.parent.current_dir + '/help.txt', 'r')
file.seek(0, 2)
size = file.tell()
file.seek(0, 0)
text = file.read(size)
file.close()
except IOError:
print('IOError while reading help text.')
return text
示例9: setup
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import theme_use [as 别名]
def setup(tk_instance):
"""Sets up all the custom styles.
Args:
Toplevel Tk instance.
"""
style = Style(tk_instance)
style.theme_use('default')
style.configure(GRID_FRAME, background='#888')
style.configure(BOX_FRAME, background='white')
style.configure(GIVEN_FRAME, background='#ddd')
style.configure(NUMBER_LABEL, background='white', font='Helvetica 24')
style.configure(GIVEN_LABEL, background='#ddd', font='Helvetica 24 bold')
style.configure(PENCIL_LABEL, background='white', font='Helvetica 8')
style.configure(GREEN, background='green')
style.configure(RED, background='red')
style.configure(YELLOW, background='yellow')
示例10: PwRd
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import theme_use [as 别名]
class PwRd(Frame):
def __init__(self,parent):
Frame.__init__(self, parent,background="white")
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Start")
self.style=Style()
self.style.theme_use("default")
frame = Frame(self,relief=RAISED,borderwidth=1,background="white")
frame.pack(fill=BOTH, expand=1)
self.pack(fill=BOTH, expand=1)
closeButton = Button(self, text="Close",command=self.quit)
closeButton.pack(side=RIGHT, padx=5, pady=5)
okButton = Button(self, text="OK")
okButton.pack(side=RIGHT)
示例11: MM_Window
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import theme_use [as 别名]
class MM_Window(Frame):
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()
self.initUI()
def initUI(self):
self.parent.title("Quit button")
self.style = Style()
self.style.theme_use("default")
# self.pack(fill=BOTH, expand=1)
quitButton = Button(self, text="Quit",
command=self.quit)
quitButton.place(x=200, y=50)
buttons_list = []
g=0
c=0
for i in range(1,52):
crnt_button = Label(self, text=str(i),background=FF0000)
crnt_button.grid(row=g, column=c)
buttons_list.append(crnt_button)
c += 1
if i%10 ==0:
g +=1
c=0
def centerWindow(self):
w = 290
h = 150
sw = self.parent.winfo_screenwidth()
sh = self.parent.winfo_screenheight()
x = (sw - w)/2
y = (sh - h)/2
self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y))
示例12: GPACalc
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import theme_use [as 别名]
class GPACalc(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def onPressCalc():
print("Hello world")
def initUI(self):
self.parent.title("GPA Calculator")
self.style = Style()
self.style.theme_use("default")
frame = Frame(self, relief=RAISED, borderwidth=1)
frame.pack(fill=BOTH, expand=True)
self.pack(fill=BOTH, expand=True)
calculateButton = Button(self, text="Calculate", command=lambda: self.onPressCalc)
calculateButton.pack(side=RIGHT, padx=5, pady=5)
示例13: Example
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import theme_use [as 别名]
class Example(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Windows")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
self.columnconfigure(1, weight=1)
self.columnconfigure(3, pad=7)
self.rowconfigure(3, weight=1)
self.rowconfigure(5, pad=7)
lbl = Label(self, text="Windows")
lbl.grid(sticky=W, pady=4, padx=5)
area = Text(self)
area.grid(row=1, column=0, columnspan=2, rowspan=4,
padx=5, sticky=E+W+S+N)
abtn = Button(self, text="Activate")
abtn.grid(row=1, column=3)
cbtn = Button(self, text="Close")
cbtn.grid(row=2, column=3, pady=4)
hbtn = Button(self, text="Help")
hbtn.grid(row=5, column=0, padx=5)
obtn = Button(self, text="OK")
obtn.grid(row=5, column=3)
示例14: Example
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import theme_use [as 别名]
class Example(Frame):
# subclase Frame, this is a container.
def __init__(self, parent):
# create frame within parent
Frame.__init__(self, parent)
# call superclass initializer
self.parent = parent # parent window
self.initUI()
def initUI(self):
self.parent.title("Press OK when done")
# Set root window title
self.style = Style()
self.style.theme_use("default")
# styles are 'clam' 'default' 'alt' or 'classic', but so far seem the same
frame = Frame(self, relief=RAISED, borderwidth=1)
# border width of one means the effect is subtle; it really just
# puts a line between the top section and the bottom buttons
frame.pack(fill=BOTH, expand=1)
# this frame has nothing, but pushes buttons down
self.pack(fill=BOTH, expand=1)
closeButton = Button(self, text="Close", command=self.quit)
closeButton.pack(side=RIGHT, padx=5, pady=5)
okButton = Button(self, text="OK")
okButton.pack(side=RIGHT)
self.pack(fill=BOTH, expand=1)
# pack geometry manager with expand in both directions
def center_main_window(self, width=290, height=150):
screen_width = self.parent.winfo_screenwidth()
screen_height = self.parent.winfo_screenheight()
new_x = (screen_width - width) // 2
new_y = (screen_height - height) // 2
self.parent.geometry('{}x{}+{}+{}'.format(width, height, new_x, new_y))
示例15: directview
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import theme_use [as 别名]
class directview(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Windows")
self.style = Style()
self.style.theme_use("default")
self.pack(fill = BOTH, expand = 1)
self.columnconfigure(1, weight = 1)
self.columnconfigure(3, pad = 7)
self.rowconfigure(3, weight = 1)
self.rowconfigure(5, pad = 7)
lbl = Label(self, text = "Windows")
lbl.grid(sticky = W, pady = 4, padx = 5)
area = Text(self)
area.grid(row = 1, column = 0, columnspan = 2, rowspan = 4,
padx = 5, sticky = E + W + S + N)
selectbtn = Button(self, text ="Select")
selectbtn.grid(row = 1, column = 3, pady = 4)
backbtn = Button(self, text ="<<")
backbtn.grid(row = 2, column = 3)
helpbtn = Button(self, text = "Help")
helpbtn.grid(row = 5, column = 0, padx = 5)
closebtn = Button(self, text = "Close")
closebtn.grid(row = 5, column = 3)