本文整理汇总了Python中ttk.Style.configure方法的典型用法代码示例。如果您正苦于以下问题:Python Style.configure方法的具体用法?Python Style.configure怎么用?Python Style.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ttk.Style
的用法示例。
在下文中一共展示了Style.configure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initUI
# 需要导入模块: from ttk import Style [as 别名]
# 或者: from ttk.Style import configure [as 别名]
def initUI(self):
self.parent.title("Absolute positioning")
self.pack(fill=BOTH, expand=1)
style = Style()
style.configure("TFrame", background="#333")
bard = Image.open("bardejov.jpg")
bardejov = ImageTk.PhotoImage(bard)
#We create an image object and a photo image object from an image in the current working directory.
label1 = Label(self, image=bardejov)
#We create a Label with an image. Labels can contain text or images.
label1.image = bardejov
#We must keep the reference to the image to prevent image from being garbage collected.
label1.place(x=20, y=20)
#The label is placed on the frame at x=20, y=20 coordinates.
rot = Image.open("rotunda.jpg")
rotunda = ImageTk.PhotoImage(rot)
label2 = Label(self, image=rotunda)
label2.image = rotunda
label2.place(x=40, y=160)
minc = Image.open("mincol.jpg")
mincol = ImageTk.PhotoImage(minc)
label3 = Label(self, image=mincol)
label3.image = mincol
label3.place(x=170, y=50)
示例2: initUI
# 需要导入模块: from ttk import Style [as 别名]
# 或者: from ttk.Style import configure [as 别名]
def initUI(self):
self.parent.title("Absolute positioning")
self.pack(fill=BOTH, expand=1)
style = Style()
style.configure("TFrame", background="#333")
示例3: ticketWindow
# 需要导入模块: from ttk import Style [as 别名]
# 或者: from ttk.Style import configure [as 别名]
class ticketWindow(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.parent.title("Zendesk Views")
self.style = Style()
self.style.theme_use("default")
self.style.configure("TFrame", background="#333")
self.style.configure("TLabel", backgroun="#444")
self.pack(fill=BOTH, expand=1)
self.centerWindow()
ticket1 = ticketViews(parent, 26887076)
ticket2 = ticketViews(parent, 35868228)
def centerWindow(self):
w = 250
h = 100
sw = self.parent.winfo_screenwidth()
sh = self.parent.winfo_screenheight()
x = (sw) /2
y = (sh) /2
self.parent.geometry('%dx%d+%d+%d' % (w, h ,x ,y))
def createQuit(self):
quitButton = Button(self, text="Quit", command=self.quit)
quitButton.place(x=50, y=50)
示例4: SetupStyles
# 需要导入模块: from ttk import Style [as 别名]
# 或者: from ttk.Style import configure [as 别名]
def SetupStyles(self):
if TTK:
style = Style(self.master)
style.configure('Color.TLabel', foreground=self.fg,
background=self.bg)
style.configure('Color.TFrame', background=self.bg)
self.ttkstyle = style
self.style = lambda w, style: w.configure(style=style)
else:
self.style = PoorManStyle(self,
styles={'Color.TLabel': {'fg': self.fg, 'bg': self.bg},
'Color.TFrame': {'bg': self.bg}}).style_it
示例5: TrackFrame
# 需要导入模块: from ttk import Style [as 别名]
# 或者: from ttk.Style import configure [as 别名]
class TrackFrame(Frame):
def __init__(self, master, track):
Frame.__init__(self, master)
self.track = track
self.style_class = Style()
self.style_class.configure('Track.TFrame',
background='black',
borderwidth=2,
# relief='raised',
)
self.config(style='Track.TFrame')
示例6: test
# 需要导入模块: from ttk import Style [as 别名]
# 或者: from ttk.Style import configure [as 别名]
def test():
tkroot = Tk()
s = Style()
s.configure('Title.TLabel', font="ariel 20 bold")
s.configure('TButton', font="ariel 14 bold")
tkroot.option_add("*TButton.Font", "ariel 12 bold")
tkroot.option_add("*Label.Font", "Helvetica 10")
fail_str = "LogFinalTestStatus RT_Final='FAIL'\n+++OUT OF RANGE+++ F1_TX0_IQOffset == -16.2532762607\n+++OUT OF RANGE+++ F1_TX1_PwrDac == 28\n+++OUT OF RANGE+++ F1_TX1_DataEvm == -31.6506357937\n+++OUT OF RANGE+++ F1_TX1_IQOffset == -2.30501317739\n+++OUT OF RANGE+++ F2_TX0_IQOffset == -15.214029339\n+++OUT OF RANGE+++ F2_TX1_DataEvm == -30.5567960708\n+++OUT OF RANGE+++ F2_TX1_IQOffset == -12.6593769606"
StatusWindow( tkroot, "Test Status -- 00:27:22:DA:00:01", "PASS\n".rstrip() )
StatusWindow( tkroot, "Test Status -- 00:27:22:DA:00:01", "FAIL\n".rstrip(), fail_str )
示例7: __init__
# 需要导入模块: from ttk import Style [as 别名]
# 或者: from ttk.Style import configure [as 别名]
def __init__(self, parent, dicogis_path="../../"):
"""Instanciating the output workbook."""
self.parent = parent
Frame.__init__(self)
logging.info('Isogeo PySDK version: {0}'.format(pysdk_version))
# logo
ico_path = path.join(path.abspath(dicogis_path),
"data/img/DicoGIS_logo.gif")
self.icone = PhotoImage(master=self,
file=ico_path)
Label(self,
borderwidth=2,
image=self.icone).grid(row=1, columnspan=2,
column=0, padx=2,
pady=2, sticky=W)
# credits
s = Style(self)
s.configure('Kim.TButton', foreground='DodgerBlue', borderwidth=0)
btn_credits = Button(self,
text='by @GeoJulien\nGPL3 - 2017',
style='Kim.TButton',
command=lambda: open_new_tab('https://github.com/Guts/DicoGIS'))
btn_credits.grid(row=2,
columnspan=2,
padx=2,
pady=2,
sticky="WE")
# contact
mailto = "mailto:DicoGIS%20Developer%20"\
"<[email protected]>?"\
"subject=[DicoGIS]%20Question"
btn_contact = Button(self,
text="\U00002709 " + "Contact",
command=lambda: open_new_tab(mailto))
# source
url_src = "https://github.com/Guts/DicoGIS/issues"
btn_src = Button(self,
text="\U000026A0 " + "Report",
command=lambda: open_new_tab(url_src))
# griding
btn_contact.grid(row=3, column=0, padx=2, pady=2,
sticky="WE")
btn_src.grid(row=3, column=1, padx=2, pady=2,
sticky="EW")
示例8: _initUI
# 需要导入模块: from ttk import Style [as 别名]
# 或者: from ttk.Style import configure [as 别名]
def _initUI(self):
self.parent.title("Pydle v" + self.version)
self.parent.minsize(width=str(self.screenWidth), height=str(self.screenHeight))
# self.parent.config(border=0)
# Styles
style = Style()
style.configure("TFrame", background="gray", border=0)
style.configure("TButton", background="gray", foreground="lightgray", highlightforeground="black", highlightbackground="darkgray", compound=RIGHT, relief=FLAT)
self.config(style="TFrame")
self.pack(fill=BOTH, expand=1)
# Menus
mnuBar = Menu(self.parent)
self.parent.config(menu=mnuBar)
mnuFile = Menu(mnuBar, background="gray")
mnuFile.add_command(label="Exit", command=self.onExitMnu)
mnuBar.add_cascade(label="File", menu=mnuFile)
mnuHelp = Menu(mnuBar, background="gray")
mnuHelp.add_command(label="About", command=self.onAboutMnu)
mnuBar.add_cascade(label="Help", menu=mnuHelp)
# Frame content
frmBooks = Frame(self, style="TFrame")
frmBooks.pack(side=LEFT, anchor=N+W, fill=BOTH, expand=1, padx=(self.padding, self.padding / 2), pady=self.padding)
self.lstBooks = Listbox(frmBooks)
self.lstBooks.config(background="lightgray", foreground="black", borderwidth=0)
self.lstBooks.pack(fill=BOTH, expand=1)
frmButtons = Frame(self)
frmButtons.pack(anchor=N+E, padx=(self.padding / 2, self.padding), pady=self.padding)
btnLoadBooks = Button(frmButtons, text="Load Books", style="TButton", command=self.onLoadBooksBtn)
btnLoadBooks.pack(side=TOP, fill=X)
btnGetNotes = Button(frmButtons, text="Get Notes", style="TButton", command=self.onGetNotesBtn)
btnGetNotes.pack(side=TOP, fill=X)
btnBackupBook = Button(frmButtons, text="Backup Book", style="TButton", command=self.onBackupBtn)
btnBackupBook.pack(side=TOP, fill=X)
btnBackupAllBooks = Button(frmButtons, text="Backup All Books", style="TButton", command=self.onBackupAllBtn)
btnBackupAllBooks.pack(side=TOP, fill=X)
示例9: FirstWindow
# 需要导入模块: from ttk import Style [as 别名]
# 或者: from ttk.Style import configure [as 别名]
class FirstWindow(Frame):
def __init__(self, parent, controller, listener):
Frame.__init__(self, parent)
self.parent = parent
self.controller = controller
self.listener = listener
self.controller.add_listener(self.listener)
self.initUI()
def initUI(self):
self.centerWindow()
self.parent.title("Cursor")
self.style = Style()
self.style.theme_use("clam")
self.style.configure("TFrame")
self.pack(fill=BOTH, expand=1)
self.label = Label(self)
self.label.configure(text="Hold your hand above the device for two seconds...")
self.label.place(x=50, y=50)
quitButton = Button(self, text="Quit",
command=self.quit)
quitButton.place(x=50, y=100)
def update_label(self):
self.label.configure(text="You can now use the cursor.")
def remove(self):
self.controller.remove_listener(self.listener)
def centerWindow(self):
w, h = 450, 180
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))
示例10: test
# 需要导入模块: from ttk import Style [as 别名]
# 或者: from ttk.Style import configure [as 别名]
def test():
tkroot = Tk()
s = Style()
s.configure('Title.TLabel', font="ariel 20 bold")
s.configure('TButton', font="ariel 14 bold")
tkroot.option_add("*TButton.Font", "ariel 12 bold")
tkroot.option_add("*Label.Font", "Helvetica 12 bold")
# tkroot.tk.call('wm', 'iconbitmap', tkroot._w, '-default', './bmp/scope.ico')
tkroot.title('test_station.ini Test')
cfg = test_station_cfg()
cfg.print_cfg()
frame = ConfigFrame(tkroot, cfg)
frame.grid()
tkroot.mainloop()
示例11: initUI
# 需要导入模块: from ttk import Style [as 别名]
# 或者: from ttk.Style import configure [as 别名]
def initUI(self):
self.parent.title("Absolute positioning")
self.pack(fill=BOTH, expand=1)
style = Style()
style.configure("TFrame", background="lightgreen")
image1=Image.open("images.jpg")
images = ImageTk.PhotoImage(image1)
label1=Label(self, image = images)
label1.image = images
label1.place(x=20,y=20)
image1=Image.open("images.jpg")
images = ImageTk.PhotoImage(image1)
label2=Label(self, image = images)
label2.image = images
label2.place(x=20,y=215)
image1=Image.open("images.jpg")
images = ImageTk.PhotoImage(image1)
label3=Label(self, image = images)
label3.image = images
label3.place(x=280,y=20)
示例12: create_styles
# 需要导入模块: from ttk import Style [as 别名]
# 或者: from ttk.Style import configure [as 别名]
def create_styles(self):
""""""
styles = Style()
styles.configure("TNotebook", background="#afc8e1", borderwidth=0, relief=FLAT, highlightthickness=0)
示例13: calc_pad
# 需要导入模块: from ttk import Style [as 别名]
# 或者: from ttk.Style import configure [as 别名]
#.........这里部分代码省略.........
if selected:
index = int(selected[0])
if index < listbox.size() - 1:
listbox.selection_clear(index)
listbox.selection_set(index + 1)
listbox.see(index + 1)
else:
if listbox.size():
listbox.selection_set(0)
listbox.see(0)
#-----------------------------------------------------------------
calc_pad.button_text = ('1', '2', '3', 'C',
'4', '5', '6', '<',
'7', '8', '9', 'X',
'0', '.', u'Ввод')
calc_pad.button_text_operation = ('C', 'X', '<', u'Ввод')
calc_pad.operation = ''
calc_pad.number = 0
calc_pad.new = True
calc_pad.cent = 0
window_calc = Toplevel()
window_calc.resizable(False, False)
window_calc.title(u'Расходы')
window_calc.geometry('+%d+%d' % (calc_pad.x, calc_pad.y))
# потом переписать в общие стили
style = Style(window_calc)
style.configure('Number.TButton', foreground='blue', justify='center',
font=('Lucida Console', CALC_SCALE, 'bold'))
style.configure('Operation.TButton', foreground='red', justify='center',
font=('Lucida Console', CALC_SCALE, 'bold'))
#=======
calc_pad.string = StringVar()
calc_pad.string.set('0')
label = Label(window_calc, textvariable = calc_pad.string,
width=13, bg='white', justify=RIGHT,
font=('Lucida Console', CALC_SCALE, 'bold'), anchor=E)
label.grid(column=0, row=0, columnspan=4, padx=CALC_PAD, pady=CALC_PAD*2)
buttons = []
for but in calc_pad.button_text:
if but in calc_pad.button_text_operation:
buttons.append(Button(window_calc, text=but,
style='Operation.TButton', width=1,
command=lambda but=but: press_operation(but)))
else:
buttons.append(Button(window_calc,
text=but,
style='Number.TButton',
width=1,
command=lambda but=but: press_number(but)))
for y in range(1, 4):
for x in range(0, 3):
buttons[x+(y-1)*4].grid(column=x, row=y, padx=CALC_PAD,
pady=CALC_PAD, ipadx=CALC_SCALE/3*2, ipady=CALC_SCALE/2)
buttons[3].grid(column=3, row=1, padx=CALC_PAD, pady=CALC_PAD,
ipadx=CALC_SCALE/3*2, ipady=CALC_SCALE/2)
示例14: last_page
# 需要导入模块: from ttk import Style [as 别名]
# 或者: from ttk.Style import configure [as 别名]
# workaround for bug #1878298 at tktoolkit sf bug tracker
self.event_generate('<Expose>')
def last_page(self):
"""Return the last page in the notebook."""
return self.pages[self.tab(self.index('end') - 1)['text']]
if __name__ == '__main__':
from Tkinter import Tk
from Tkconstants import TOP, BOTH
from ttk import Label, Entry, Button, Style
# test dialog
root=Tk()
style = Style()
style.configure('C.TLabel', padding=20)
tabPage=TabbedPageSet(root, page_names=['Foobar','Baz'])
tabPage.pack(side=TOP, expand=True, fill=BOTH)
Label(tabPage.pages['Foobar'].frame, text='Foo', style='C.TLabel').pack()
Label(tabPage.pages['Foobar'].frame, text='Bar', style='C.TLabel').pack()
Label(tabPage.pages['Baz'].frame, text='Baz').pack()
entryPgName=Entry(root)
buttonAdd=Button(root, text='Add Page',
command=lambda:tabPage.add_page(entryPgName.get()))
buttonRemove=Button(root, text='Remove Page',
command=lambda:tabPage.remove_page(entryPgName.get()))
labelPgName=Label(root, text='name of page to add/remove:')
buttonAdd.pack(padx=5, pady=5)
buttonRemove.pack(padx=5, pady=5)
labelPgName.pack(padx=5)
entryPgName.pack(padx=5)
示例15: __init__
# 需要导入模块: from ttk import Style [as 别名]
# 或者: from ttk.Style import configure [as 别名]
def __init__(self, master, columns, data=None, command=None, sort=True, select_mode=None, heading_anchor = CENTER, cell_anchor=W, style=None, height=None, padding=None, adjust_heading_to_content=False, stripped_rows=None, selection_background=None, selection_foreground=None, field_background=None, heading_font= None, heading_background=None, heading_foreground=None, cell_pady=2, cell_background=None, cell_foreground=None, cell_font=None, headers=True):
self._stripped_rows = stripped_rows
self._columns = columns
self._number_of_rows = 0
self._number_of_columns = len(columns)
self.row = self.List_Of_Rows(self)
self.column = self.List_Of_Columns(self)
s = Style()
if style is None:
style_name = "Multicolumn_Listbox%s.Treeview"%self._style_index
self._style_index += 1
else:
style_name = style
style_map = {}
if selection_background is not None:
style_map["background"] = [('selected', selection_background)]
if selection_foreground is not None:
style_map["foeground"] = [('selected', selection_foreground)]
if style_map:
s.map(style_name, **style_map)
style_config = {}
if cell_background is not None:
style_config["background"] = cell_background
if cell_foreground is not None:
style_config["foreground"] = cell_foreground
if cell_font is None:
font_name = s.lookup(style_name, "font")
cell_font = nametofont(font_name)
else:
if not isinstance(cell_font, Font):
if isinstance(cell_font, basestring):
cell_font = nametofont(cell_font)
else:
if len(font) == 1:
cell_font = Font(family=cell_font[0])
elif len(font) == 2:
cell_font = Font(family=cell_font[0], size=cell_font[1])
elif len(font) == 3:
cell_font = Font(family=cell_font[0], size=cell_font[1], weight=cell_font[2])
else:
raise ValueError("Not possible more than 3 values for font")
style_config["font"] = cell_font
self._cell_font = cell_font
self._rowheight = cell_font.metrics("linespace")+cell_pady
style_config["rowheight"]=self._rowheight
if field_background is not None:
style_config["fieldbackground"] = field_background
s.configure(style_name, **style_config)
heading_style_config = {}
if heading_font is not None:
heading_style_config["font"] = heading_font
if heading_background is not None:
heading_style_config["background"] = heading_background
if heading_foreground is not None:
heading_style_config["foreground"] = heading_foreground
heading_style_name = style_name + ".Heading"
s.configure(heading_style_name, **heading_style_config)
treeview_kwargs = {"style": style_name}
if height is not None:
treeview_kwargs["height"] = height
if padding is not None:
treeview_kwargs["padding"] = padding
if headers:
treeview_kwargs["show"] = "headings"
else:
treeview_kwargs["show"] = ""
if select_mode is not None:
treeview_kwargs["selectmode"] = select_mode
self.interior = Treeview(master, columns=columns, **treeview_kwargs)
if command is not None:
self._command = command
self.interior.bind("<<TreeviewSelect>>", self._on_select)
#.........这里部分代码省略.........