本文整理汇总了Python中tkinter.ttk.Style.configure方法的典型用法代码示例。如果您正苦于以下问题:Python Style.configure方法的具体用法?Python Style.configure怎么用?Python Style.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.ttk.Style
的用法示例。
在下文中一共展示了Style.configure方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import configure [as 别名]
def __init__(self, parent):
Notebook.__init__(self, parent, style='Type.TNotebook')
logger = logging.getLogger(__name__)
s = Style()
s.configure('Type.TNotebook', tabposition="se")
self.page_tiborcim = Frame(self)
self.page_python = Frame(self)
self.add(self.page_tiborcim, text='Tiborcim')
self.add(self.page_python, text='Python')
self.text_tiborcim = CimTiborcimText(self.page_tiborcim, self)
self.vbar_python = Scrollbar(self.page_python, name='vbar_python')
self.xbar_python = Scrollbar(self.page_python, name='xbar_python', orient="horizontal")
self.text_python = Text(self.page_python, wrap="none", state="disabled", borderwidth='0p')
self.vbar_python['command'] = self.text_python.yview
self.vbar_python.pack(side="right", fill="y")
self.text_python['yscrollcommand'] = self.vbar_python.set
self.xbar_python['command'] = self.text_python.xview
self.xbar_python.pack(side="bottom", fill="x")
self.text_python['xscrollcommand'] = self.xbar_python.set
self.text_python.pack(expand=1, fill="both")
self.viewmode = "tiborcim"
self.saved = True
self.filename = None
示例2: __init__
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import configure [as 别名]
def __init__(self, widget):
self.widget = widget
self.widget.bind("<Enter>", self.show)
self.widget.bind("<Leave>", self.hide)
self.tooltip = None
style = Style()
style.configure("tt.TLabel", background="#fbfbf4", foreground="#333333")
示例3: MainWindow
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import configure [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)
示例4: main
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import configure [as 别名]
def main():
''' Runs main application GUI.
'''
logger = get_logger()
logger.info('pyDEA started as a GUI application.')
root = Tk()
root.report_callback_exception = show_error
# load logo
if "nt" == os.name:
iconfile = pkg_resources.resource_filename(PACKAGE, 'pyDEAlogo.ico')
root.wm_iconbitmap(bitmap=iconfile)
else:
iconfile = pkg_resources.resource_filename(PACKAGE, 'pyDEAlogo.gif')
img = PhotoImage(file=iconfile)
root.tk.call('wm', 'iconphoto', root._w, img)
# change background color of all widgets
s = Style()
s.configure('.', background=bg_color)
# run the application
app = MainFrame(root)
root.protocol("WM_DELETE_WINDOW", (lambda: ask_quit(app)))
center_window(root,
root.winfo_screenwidth() - root.winfo_screenwidth()*0.15,
root.winfo_screenheight() - root.winfo_screenheight()*0.15)
root.mainloop()
logger.info('pyDEA exited.')
示例5: create_frame
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import configure [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)
示例6: initUI
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import configure [as 别名]
def initUI(self, mainFrame):
"""initialize the User Interface"""
# styles
style = Style()
style.configure("GRN.TLabel", background="#ACF059")
style.configure("GRN.TFrame", background="#ACF059")
style.configure("BLK.TFrame", background="#595959")
# create top frame
topFrame = Frame(mainFrame, style="GRN.TFrame", padding=8)
topFrame.pack(fill=BOTH, side=TOP)
# create black border
borderFrame = Frame(mainFrame, style="BLK.TFrame")
borderFrame.pack(fill=BOTH, side=TOP)
# create add player frame
addPlayerFrame = Frame(mainFrame, padding=8)
addPlayerFrame.pack(side=TOP)
# create text field for add button
self.nameFieldVar = StringVar()
self.playerNameEntry = Entry(addPlayerFrame, textvariable = self.nameFieldVar)
self.playerNameEntry.pack(side=LEFT)
# create add player button
addButton = Button(addPlayerFrame, text="Add player")
addButton.pack(side=LEFT)
# create choose game list
self.currentGame = StringVar()
self.currentGame.set(self.gameList[0])
gameDropDown = OptionMenu(mainFrame, self.currentGame, self.gameList[0], *self.gameList)
gameDropDown.pack(side=TOP)
# create start game button
startGameButton = Button(mainFrame, text="Start")
startGameButton.bind("<Button-1>", self.startGame)
startGameButton.pack(side=TOP)
# create label and set text
self.playerString = StringVar()
self.playerString.set(self.buildPlayerHeaderString())
headerLabel = Label(topFrame, textvariable=self.playerString, style="GRN.TLabel")
headerLabel.pack(side=TOP)
addButton.bind("<Button-1>", self.onAddPlayerClick)
self.playerNameEntry.bind("<Key>", self.onAddPlayerEnter)
#set focus
self.playerNameEntry.focus()
示例7: main
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import configure [as 别名]
def main():
log = logging.getLogger()
log.setLevel(logging.ERROR)
parser = argparse.ArgumentParser(description='Run stuff')
parser.add_argument('--server', action='store_true', default=False)
parser.add_argument('--debug', action='store_true', default=False)
parser.add_argument('--file_root', default=os.path.expanduser('~'))
parser.add_argument('--full', action='store_true', default=False)
args = parser.parse_args()
if args.debug:
log.setLevel(logging.DEBUG)
root = Tk()
config = Config()
config.full_screen = args.full
config.set_file_root(os.path.expanduser(args.file_root))
s = Style()
s.configure('Treeview', rowheight=config.tree_item_height)
s.configure('TButton', font='Helvetica 16')
s.configure('Vertical.TScrollbar', arrowsize=config.sb_size)
if args.server:
fs = FileServer(config.web_port, config)
fs.run(debug=True)
else:
root.title('copilot')
app = HomeFrame(root, config)
root.mainloop()
示例8: SecondaryWindow
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import configure [as 别名]
class SecondaryWindow(TkApplication):
def _create_ui(self):
self.pygubu_builder = Builder()
self.pygubu_builder.add_from_file(path.join(SCRIPT_DIR, "forms", "secondary_window.ui"))
self.style = Style()
self.canvas = list()
self.predator_draw_object = [None, None, None, None]
self.current_background_color = BACKGROUND_COLOR
self.setup()
def setup(self):
self.set_title("Piscis")
self.pygubu_builder.get_object('main_frame', self.master)
self.canvas.append(self._create_canvas('canvas_one'))
self.canvas.append(self._create_canvas('canvas_two'))
self.canvas.append(self._create_canvas('canvas_three'))
self.canvas.append(self._create_canvas('canvas_four'))
self.change_background_color(BACKGROUND_COLOR)
def _create_canvas(self, identifier):
return self.pygubu_builder.get_object(identifier, self.master)
def set_fullscreen(self):
self.master.overrideredirect(True)
self.master.geometry("%dx%d+0+0" % (self.master.winfo_screenwidth(), self.master.winfo_screenheight()))
def change_background_color(self, color):
self.style.configure('TFrame', background=color)
self.current_background_color = color
def change_canvas_background(self, color, id_number):
self.canvas[id_number].configure(background=color)
示例9: configure_ui
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import configure [as 别名]
def configure_ui(info):
"""
UI config function.
@param info: UI config info dict.
@return: None.
"""
# Background color
bg_color = 'white smoke'
# Create ttk style object
STYLE = Style()
# Configure TFrame style's background
STYLE.configure(
'TFrame',
background=bg_color,
)
# Configure TLabelframe style's background
STYLE.configure(
'TLabelframe',
background=bg_color,
)
# Configure TLabelframe.Label style's background
STYLE.configure(
'TLabelframe.Label',
background=bg_color,
)
# Configure TLabel style's background
STYLE.configure(
'TLabel',
background=bg_color,
)
# Configure TRadiobutton style's background
STYLE.configure(
'TRadiobutton',
background=bg_color,
)
# Get TK root window
tk = info['tk']
# Set window title
tk.title('AoikRegistryEditor')
# Set window geometry
tk.geometry('1280x720')
# Configure layout weights for children.
# Row 0 is for registry editor.
tk.rowconfigure(0, weight=1)
# Row 1 is for status bar
tk.rowconfigure(1, weight=0)
# Use only one column
tk.columnconfigure(0, weight=1)
# Get menu tree
menutree = info['menutree']
# Add `File` menu
menutree.add_menu(pid='/', id='File', index=0)
# Add `Exit` command
menutree.add_command(pid='/File', id='Exit', command=tk.quit)
# Get status bar label
status_bar_label = info['status_bar_label']
# Set status bar label's main frame's height
status_bar_label.widget().config(height=20)
# Set status bar label's background
status_bar_label.config(background='#F0F0F0')
# Lay out the status bar label
status_bar_label.grid(
in_=tk,
row=2,
column=0,
sticky='NSEW',
padx=(5, 0),
)
# Create size grip
sizegrip = Sizegrip(master=tk)
# Lay out the size grip
sizegrip.grid(
in_=tk,
row=2,
column=0,
sticky='E',
)
#.........这里部分代码省略.........
示例10: MainFrame
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import configure [as 别名]
class MainFrame(Frame):
def __init__(self, parent):
super().__init__(parent)
self.parent = parent
self.parent.title("InstaDjango")
self.pack(fill=BOTH, expand=1)
self.size_and_center_window()
self.style = Style()
self.style.theme_use("clam")
self.style.configure("TFrame", background="#808080", foreground="white")
self.style.configure("TButton", background="#808080", foreground="white")
self.style.configure("high.TButton", background="#8FBC8B", foreground="white")
self.style.configure("TLabel", background="#808080", foreground="white")
self.style.map("TButton", background=[("pressed", "#404040"), ("active", "#A0A0A0")])
frame = Frame(self, relief=FLAT, borderwidth=1)
frame.pack(fill=BOTH, expand=1)
subframe_0 = Frame(frame, relief=FLAT, borderwidth=0)
subframe_0.pack(fill=X)
lbl_0 = Label(subframe_0, text="App's machine-readable name (used for naming folders locally and remotely):", style="TLabel")
lbl_0.pack(fill=BOTH, padx=10, pady=10)
entry_0 = Entry(subframe_0)
entry_0.pack(fill=X, padx=10, ipady=5)
self.set_entry_text(entry_0, "")
subframe_1 = Frame(frame, relief=FLAT, borderwidth=0)
subframe_1.pack(fill=X)
lbl_1 = Label(
subframe_1, text="Where to create the app's folder locally:", style="TLabel")
lbl_1.pack(fill=BOTH, padx=10, pady=10)
entry_1 = Entry(subframe_1)
def action_1():
cdir = filedialog.askdirectory(title="Please select a directory")
if cdir:
self.set_entry_text(entry_1, cdir)
button_1 = Button(subframe_1, text="Choose", command=action_1, style="TButton")
button_1.pack(side=RIGHT, padx=10, pady=0)
entry_1.pack(fill=X, padx=10, ipady=5)
self.set_entry_text(entry_1, "")
subframe_2 = Frame(frame, relief=FLAT, borderwidth=0)
subframe_2.pack(fill=X)
lbl_2 = Label(subframe_2, text="Remote host:", style="TLabel")
lbl_2.pack(fill=BOTH, padx=10, pady=10)
entry_2 = Entry(subframe_2)
entry_2.pack(fill=X, padx=10, ipady=5)
self.set_entry_text(entry_2, "")
subframe_3 = Frame(frame, relief=FLAT, borderwidth=0)
subframe_3.pack(fill=X)
lbl_3 = Label(
subframe_3, text="Remote SSH port (empty will mean the default port):", style="TLabel")
lbl_3.pack(fill=BOTH, padx=10, pady=10)
entry_3 = Entry(subframe_3)
entry_3.pack(fill=X, padx=10, ipady=5)
self.set_entry_text(entry_3, "")
subframe_4 = Frame(frame, relief=FLAT, borderwidth=0)
subframe_4.pack(fill=X)
lbl_4 = Label(subframe_4, text="Remote user:", style="TLabel")
lbl_4.pack(fill=BOTH, padx=10, pady=10)
entry_4 = Entry(subframe_4)
entry_4.pack(fill=X, padx=10, ipady=5)
self.set_entry_text(entry_4, "")
subframe_5 = Frame(frame, relief=FLAT, borderwidth=0)
subframe_5.pack(fill=X)
lbl_5 = Label(
subframe_5, text="Local path to the SSH private key:", style="TLabel")
lbl_5.pack(fill=BOTH, padx=10, pady=10)
entry_5 = Entry(subframe_5)
def action_5():
cdir = filedialog.askopenfilename(title="Please select a private key")
if cdir:
self.set_entry_text(entry_5, cdir)
button_5 = Button(subframe_5, text="Choose", command=action_5, style="TButton")
button_5.pack(side=RIGHT, padx=10, pady=0)
entry_5.pack(fill=X, padx=10, ipady=5)
self.set_entry_text(entry_5, "")
subframe_6 = Frame(frame, relief=FLAT, borderwidth=0)
subframe_6.pack(fill=X)
lbl_6 = Label(
subframe_6, text="Where to create the app's folder remotely (should not be owned by root):", style="TLabel")
lbl_6.pack(fill=BOTH, padx=10, pady=10)
entry_6 = Entry(subframe_6)
entry_6.pack(fill=X, padx=10, ipady=5)
self.set_entry_text(entry_6, "/var/www")
subframe_7 = Frame(frame, relief=FLAT, borderwidth=0)
subframe_7.pack(fill=X)
#.........这里部分代码省略.........
示例11: Clavier
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import configure [as 别名]
class Clavier(Toplevel):
""" Pavé numérique pour choisir un chiffre """
def __init__(self, parent, case, val_ou_pos, **options):
""" créer le Toplevel 'À propos de Bracelet Generator' """
Toplevel.__init__(self, parent, **options)
self.withdraw()
self.type = val_ou_pos # clavier pour rentrer une valeur ou une possibilité
self.overrideredirect(True)
self.case = case
self.transient(self.master)
self.style = Style(self)
self.style.configure("clavier.TButton", font="Arial 12")
self.boutons = [[Button(self, text="1", width=2, style="clavier.TButton", command=lambda: self.entre_nb(1)),
Button(self, text="2", width=2, style="clavier.TButton", command=lambda: self.entre_nb(2)),
Button(self, text="3", width=2, style="clavier.TButton", command=lambda: self.entre_nb(3))],
[Button(self, text="4", width=2, style="clavier.TButton", command=lambda: self.entre_nb(4)),
Button(self, text="5", width=2, style="clavier.TButton", command=lambda: self.entre_nb(5)),
Button(self, text="6", width=2, style="clavier.TButton", command=lambda: self.entre_nb(6))],
[Button(self, text="7", width=2, style="clavier.TButton", command=lambda: self.entre_nb(7)),
Button(self, text="8", width=2, style="clavier.TButton", command=lambda: self.entre_nb(8)),
Button(self, text="9", width=2, style="clavier.TButton", command=lambda: self.entre_nb(9))]]
for i in range(3):
for j in range(3):
self.boutons[i][j].grid(row=i, column=j)
self.protocol("WM_DELETE_WINDOW", self.quitter)
self.resizable(0, 0)
self.attributes("-topmost", 0)
def focus_out(self, event):
""" quitte si la fenêtre n'est plus au premier plan """
try:
if not self.focus_get():
self.quitter()
except KeyError:
# erreur déclenchée par la présence d'une tkMessagebox
self.quitter()
def entre_nb(self, val):
""" commande de la touche val du clavier """
i, j = self.case.get_i(), self.case.get_j()
# données pour le log
val_prec = self.case.get_val()
pos_prec = self.case.get_possibilites().copy()
modifs = []
# modification de la case
if self.type == "val":
self.master.modifie_nb_cases_remplies(self.case.edit_chiffre(val))
if not self.master.test_case(i, j, val_prec):
modifs = self.master.update_grille(i, j, val_prec)
self.quitter()
else:
self.master.modifie_nb_cases_remplies(self.case.edit_possibilite(val))
self.master.test_possibilite(i, j, val)
# données pour le log
pos = self.case.get_possibilites().copy()
val = self.case.get_val()
self.master.stacks_modif((i, j, val_prec, pos_prec, modifs, val, pos))
self.master.test_remplie()
def quitter(self):
""" ferme la fenêtre """
if self.master:
self.master.focus_set()
self.master.set_clavier(None)
self.destroy()
def set_case(self, case):
self.case = case
def display(self, geometry):
self.geometry(geometry)
self.update_idletasks()
self.deiconify()
self.focus_set()
self.lift()
self.bind("<FocusOut>", self.focus_out)
示例12: __init__
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import configure [as 别名]
def __init__(self, file=None):
Tk.__init__(self, className="Sudoku-Tk")
self.title("Sudoku-Tk")
self.resizable(0, 0)
self.protocol("WM_DELETE_WINDOW", self.quitter)
cst.set_icon(self)
self.columnconfigure(3, weight=1)
# --- style
bg = '#dddddd'
activebg = '#efefef'
pressedbg = '#c1c1c1'
lightcolor = '#ededed'
darkcolor = '#cfcdc8'
bordercolor = '#888888'
focusbordercolor = '#5E5E5E'
disabledfg = '#999999'
disabledbg = bg
button_style_config = {'bordercolor': bordercolor,
'background': bg,
'lightcolor': lightcolor,
'darkcolor': darkcolor}
button_style_map = {'background': [('active', activebg),
('disabled', disabledbg),
('pressed', pressedbg)],
'lightcolor': [('pressed', darkcolor)],
'darkcolor': [('pressed', lightcolor)],
'bordercolor': [('focus', focusbordercolor)],
'foreground': [('disabled', disabledfg)]}
style = Style(self)
style.theme_use(cst.STYLE)
style.configure('TFrame', background=bg)
style.configure('TLabel', background=bg)
style.configure('TScrollbar', gripcount=0, troughcolor=pressedbg,
**button_style_config)
style.map('TScrollbar', **button_style_map)
style.configure('TButton', **button_style_config)
style.map('TButton', **button_style_map)
style.configure('TCheckutton', **button_style_config)
style.map('TCheckutton', **button_style_map)
self.option_add('*Toplevel.background', bg)
self.option_add('*Menu.background', bg)
self.option_add('*Menu.activeBackground', activebg)
self.option_add('*Menu.activeForeground', "black")
self.configure(bg=bg)
style.configure("bg.TFrame", background="grey")
style.configure("case.TFrame", background="white")
style.configure("case.TLabel", background="white", foreground="black")
style.configure("case_init.TFrame", background="lightgrey")
style.configure("case_init.TLabel", background="lightgrey", foreground="black")
style.configure("erreur.TFrame", background="white")
style.configure("erreur.TLabel", background="white", foreground="red")
style.configure("solution.TFrame", background="white")
style.configure("solution.TLabel", background="white", foreground="blue")
style.configure("pause.TLabel", foreground="grey", background='white')
# --- images
self.im_erreur = open_image(cst.ERREUR)
self.im_pause = open_image(cst.PAUSE)
self.im_restart = open_image(cst.RESTART)
self.im_play = open_image(cst.PLAY)
self.im_info = open_image(cst.INFO)
self.im_undo = open_image(cst.UNDO)
self.im_redo = open_image(cst.REDO)
self.im_question = open_image(cst.QUESTION)
# --- timer
self.chrono = [0, 0]
self.tps = Label(self, text=" %02i:%02i" % tuple(self.chrono),
font="Arial 16")
self.debut = False # la partie a-t-elle commencée ?
self.chrono_on = False # le chrono est-il en marche ?
# --- buttons
self.b_pause = Button(self, state="disabled", image=self.im_pause,
command=self.play_pause)
self.b_restart = Button(self, state="disabled", image=self.im_restart,
command=self.recommence)
self.b_undo = Button(self, image=self.im_undo, command=self.undo)
self.b_redo = Button(self, image=self.im_redo, command=self.redo)
# --- tooltips
self.tooltip_wrapper = TooltipWrapper(self)
self.tooltip_wrapper.add_tooltip(self.b_pause, _("Pause game"))
self.tooltip_wrapper.add_tooltip(self.b_restart, _("Restart game"))
self.tooltip_wrapper.add_tooltip(self.b_undo, _("Undo"))
self.tooltip_wrapper.add_tooltip(self.b_redo, _("Redo"))
# --- numbers
frame_nb = Frame(self, style='bg.TFrame', width=36)
self.progression = []
for i in range(1, 10):
self.progression.append(Progression(frame_nb, i))
self.progression[-1].pack(padx=1, pady=1)
# --- level indication
#.........这里部分代码省略.........
示例13: setup
# 需要导入模块: from tkinter.ttk import Style [as 别名]
# 或者: from tkinter.ttk.Style import configure [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')