Python tkinter.ttk 模块,Style() 实例源码

我们从Python开源项目中,提取了以下41个代码示例,用于说明如何使用tkinter.ttk.Style()

项目:StochOPy    作者:keurfonluu    | 项目源码 | 文件源码
def main():
    """
    Start StochOPy Viewer window.
    """
    import matplotlib
    matplotlib.use("TkAgg")
    from sys import platform as _platform

    root = tk.Tk()
    root.resizable(0, 0)
    StochOGUI(root)
    s = ttk.Style()
    if _platform == "win32":
        s.theme_use("vista")
    elif _platform in [ "linux", "linux2" ]:
        s.theme_use("alt")
    elif _platform == "darwin":
        s.theme_use("aqua")
    root.mainloop()
项目:synthesizer    作者:irmen    | 项目源码 | 文件源码
def __init__(self, master):
        super().__init__(master, text="Levels", padding=4)
        self.lowest_level = Player.levelmeter_lowest
        self.pbvar_left = tk.IntVar()
        self.pbvar_right = tk.IntVar()
        pbstyle = ttk.Style()
        # pbstyle.theme_use("classic")  # clam, alt, default, classic
        pbstyle.configure("green.Vertical.TProgressbar", troughcolor="gray", background="light green")
        pbstyle.configure("yellow.Vertical.TProgressbar", troughcolor="gray", background="yellow")
        pbstyle.configure("red.Vertical.TProgressbar", troughcolor="gray", background="orange")

        ttk.Label(self, text="dB").pack(side=tkinter.TOP)
        frame = ttk.LabelFrame(self, text="L.")
        frame.pack(side=tk.LEFT)
        self.pb_left = ttk.Progressbar(frame, orient=tk.VERTICAL, length=200, maximum=-self.lowest_level, variable=self.pbvar_left, mode='determinate', style='yellow.Vertical.TProgressbar')
        self.pb_left.pack()

        frame = ttk.LabelFrame(self, text="R.")
        frame.pack(side=tk.LEFT)
        self.pb_right = ttk.Progressbar(frame, orient=tk.VERTICAL, length=200, maximum=-self.lowest_level, variable=self.pbvar_right, mode='determinate', style='yellow.Vertical.TProgressbar')
        self.pb_right.pack()
项目:Quiver    作者:DeflatedPickle    | 项目源码 | 文件源码
def body(self, master):
        ttk.Style().configure("White.TLabel", background="white")

        ttk.Label(master, image=self.logo, justify="center", style="White.TLabel").pack(pady=10)

        title = font.Font(family=font.nametofont("TkDefaultFont").cget("family"), size=15, weight="bold")
        ttk.Label(master, text=(self.program_title, self.version), font=title, justify="center",
                  style="White.TLabel").pack()

        ttk.Label(master, text=self.description, wraplength=230, justify="center", style="White.TLabel").pack()
        ttk.Label(master, text=self.copyright_text, justify="center", style="White.TLabel").pack()

        link = pk.Hyperlink(master, text="Visit the project on GitHub", link="https://github.com/DeflatedPickle/Quiver")
        link.configure(background="white", justify="center")
        link.pack(pady=3)
        link._font.configure(size=10)
项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, title="", title_command=None, info="", info_command=None, background="SystemButtonFace", *args):
        ttk.Frame.__init__(self, parent, *args)
        self.parent = parent
        self._title = title
        self._title_command = title_command
        self._info = info
        self._info_command = info_command
        self._background = background

        self.columnconfigure(1, weight=1)

        style = ttk.Style()
        style.configure("InfoBar.Toolbutton", background=self._background)
        style.configure("InfoClose.InfoBar.Toolbutton", anchor="center")

        if self._title != "":
            self._title_button = ttk.Button(self, text=self._title, style="InfoBar.Toolbutton", command=self._title_command)
            self._title_button.grid(row=0, column=0)

        self._info_button = ttk.Button(self, text=self._info, style="InfoBar.Toolbutton", command=self._info_command)
        self._info_button.grid(row=0, column=1, sticky="we")

        self._close_button = ttk.Button(self, text="x", width=2, style="InfoClose.InfoBar.Toolbutton", command=self.close)
        self._close_button.grid(row=0, column=2)
项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, width=350, padx=5, pady=45, popup_fit=5, popup_pad=5, popup_ipad=3, popup_height=100, *args):
        tk.Toplevel.__init__(self, parent, *args)
        self.parent = parent
        self._width = width
        self._padx = padx
        self._pady = pady
        self._popup_fit = popup_fit
        self._popup_pad = popup_pad
        self._popup_ipad = popup_ipad
        self._popup_height = popup_height

        self.attributes("-toolwindow", True, "-topmost", True)
        self.overrideredirect(True)

        self.geometry("{}x{}".format(self._width, self._popup_fit * (self._popup_height + (self._popup_pad * 2))))
        self.update()
        self.geometry("+{}+{}".format((self.winfo_screenwidth() - self.winfo_width()) - self._padx,
                                      (self.winfo_screenheight() - self.winfo_height()) - self._pady))

        ttk.Style().configure("Popup.TFrame", borderwidth=10, relief="raised")
        ttk.Style().configure("Close.Popup.TButton")
        ttk.Style().configure("Image.Popup.TLabel")
        ttk.Style().configure("Title.Popup.TLabel")
        ttk.Style().configure("Message.Popup.TLabel")
项目:PyTouch    作者:mNisblee    | 项目源码 | 文件源码
def __init__(self, master=Tk()):
        super(MainWindow, self).__init__(master)

        # Pack self to expand to root
        self.grid(sticky=N + E + S + W)
        # Expand main window cell inside root
        top = self.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)

        top.wm_title('PyTouch Typing Tutor')
        top.wm_iconname('PyTouch')
        # TODO: Add icon image
        # top.wm_iconphoto()

        self.training_widget = TrainingWidget(self)
        self.training_widget.grid(column=0, row=0, sticky=N + E + S + W)

        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        self.style = ttk.Style()
        if 'clam' in self.style.theme_names():
            self.style.theme_use('clam')
项目:stash-scanner    作者:senuido    | 项目源码 | 文件源码
def __init__(self, master, app_main, **kwargs):
        super().__init__(master, **kwargs)

        # style = Style()
        # if we do this we also need to hide the #0 column because it adds indention for possible children
        # style.configure("Treeview.Heading", padding=(10, 0))

        # self.protocol('WM_DELETE_WINDOW', self.onClose)
        # self.nb_tabs = Notebook(self)

        # self.create_iprice_tab()
        self.prices_editor = PricesEditor(self)
        self.currency_editor = CurrencyEditor(self)
        self.settings_editor = SettingsEditor(self, app_main)
        # self.add(self.frm_iprices_tab, text='Item Prices', sticky='nsew')

        self.add(self.settings_editor, text='General', sticky='nsew')
        self.add(self.prices_editor, text='Prices', sticky='nsew')
        self.add(self.currency_editor, text='Currency', sticky='nsew')
        self.bind('<<NotebookTabChanged>>', self.onTabChange)

        self.settings_editor_id, self.prices_tab_id, self.currency_tab_id = self.tabs()
项目:stash-scanner    作者:senuido    | 项目源码 | 文件源码
def __init__(self, master, **kw):
        super().__init__(master)

        # self.grid_propagate(0)
        # self.columnconfigure(0, weight=1)
        # self.rowconfigure(0, weight=1)

        self.var = kw.get('variable', IntVar())
        kw['variable'] = self.var
        kw['from_'] = ConfidenceLevel.Low.value
        kw['to'] = ConfidenceLevel.VeryHigh.value
        # kw['command'] = self.scale_change
        kw['orient'] = HORIZONTAL

        self.lbl_scale = Label(self)
        self.scale = Scale(self, **kw)

        self.scale_font = tkfont.nametofont(Style().lookup('TLabel', 'font')).copy()
        self.scale_font.config(weight=tkfont.BOLD, size=9)
        self.lbl_scale.config(font=self.scale_font, width=3, anchor=CENTER)
        self.var.trace_variable('w', lambda a, b, c: self.scale_change())

        self.scale.grid(row=0, column=0, sticky='ns')
        self.lbl_scale.grid(row=0, column=1, sticky='ns', padx=(3, 0))
项目:sorter    作者:giantas    | 项目源码 | 文件源码
def __init__(self, logger):
        super(Loader, self).__init__()
        self.overrideredirect(True)

        # Set logger
        self.logger = logger

        # Configure default theme
        style = ttk.Style(self)
        style.theme_use('clam')
        self.bg = self.cget('bg')
        style.configure('My.TFrame', background=self.bg)
        style.configure("blue.Horizontal.TProgressbar",
                        background='#778899', troughcolor=self.bg)
        self.geometry('{0}x{1}+{2}+{3}'.format(300, 200, 230, 250))
        self._init_ui()
项目:PyTasks    作者:TheHirschfield    | 项目源码 | 文件源码
def calenderStyleWidget(self):
        style = ttk.Style(self.master)
        styleArrowLayout = lambda dir: (
            [('Button.focus', {'children': [('Button.%sarrow' % dir, None)]})]
        )
        style.layout('L.TButton', styleArrowLayout('left'))
        style.layout('R.TButton', styleArrowLayout('right'))
        style.configure('Calendar.Treeview', rowheight=40)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def get_background_of_widget(widget):
    try:
        # We assume first tk widget
        background = widget.cget("background")
    except:
        # Otherwise this is a ttk widget
        style = widget.cget("style")

        if style == "":
            # if there is not style configuration option, default style is the same than widget class
            style = widget.winfo_class()

        background = Style().lookup(style, 'background')

    return background
项目:Quiver    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, title="Dialog", transient=True, resizable=(False, False), geometry="300x300", separator=False, background="white", *args,
                 **kwargs):
        tk.Toplevel.__init__(self, parent)
        self.parent = parent

        self.title(title)

        ttk.Style().configure("White.TFrame", background=background)

        frame = ttk.Frame(self, style="White.TFrame")
        self.initial_focus = self.body(frame)
        frame.pack(fill="both", expand=True)

        if separator:
            ttk.Separator(self).pack(fill="x")

        self.buttonbox()

        self.update()

        if transient:
            self.transient(self.parent)

        if geometry:
            self.geometry(geometry)

        if resizable:
            self.resizable(resizable[0], resizable[1])

        pk.center_on_parent(self)
        self.grab_set()
项目:Quiver    作者:DeflatedPickle    | 项目源码 | 文件源码
def body(self, master):
        ttk.Style().configure("White.TLabel", background="white")

        self.variable_name = tk.StringVar()
        name = ttk.Label(master, textvariable=self.variable_name, style="White.TLabel")
        name.pack(anchor="w", padx=20, pady=[10, 0])

        self.variable_percent = tk.StringVar()
        percent = ttk.Label(master, textvariable=self.variable_percent, style="White.TLabel")
        percent.pack(anchor="w", padx=20, pady=[0, 10])

        self.variable_progress = tk.IntVar()
        progress = ttk.Progressbar(master, variable=self.variable_progress, maximum=self.maximum)
        progress.pack(fill="x", padx=20, pady=[0, 10])
项目:Quiver    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, title="Manage Packs", *args, **kwargs):
        TreeDialog.__init__(self, parent, title=title, background=ttk.Style().lookup("TFrame", "background"), separator=True, *args, **kwargs)
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def setUp(self):
        super().setUp()
        self.style = ttk.Style(self.root)
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def setUp(self):
        super().setUp()
        self.style = ttk.Style(self.root)
项目:spe2fits    作者:jerryjiahaha    | 项目源码 | 文件源码
def initUI(self):
        self.parent.title("PI/WinViewer .SPE to FITS Converter")
        self.parent.geometry(self.screenAutoSize())
        self.pack(fill = tk.BOTH, expand = 1)
        self.style = ttk.Style()
        self.style.theme_use("default")
项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, bordercolour="dark grey", borderspan=5, *args):
        tk.Tk.__init__(self, *args)
        self.bordercolour = bordercolour
        self.borderspan = borderspan
        self.overrideredirect(True)
        self.rowconfigure(1, weight=1)
        self.columnconfigure(1, weight=1)

        ttk.Style().configure("Border.TFrame", background=self.bordercolour)

        self.nwf = ttk.Frame(self, width=self.borderspan, height=self.borderspan, style="Border.TFrame")
        self.nwf.grid(row=0, column=0, sticky="nesw")
        self.nf = ttk.Frame(self, height=self.borderspan, style="Border.TFrame")
        self.nf.grid(row=0, column=1, sticky="nesw")
        self.nef = ttk.Frame(self, width=self.borderspan, height=self.borderspan, style="Border.TFrame")
        self.nef.grid(row=0, column=2, sticky="nesw")

        self.wf = ttk.Frame(self, width=self.borderspan, style="Border.TFrame")
        self.wf.grid(row=1, column=0, sticky="nesw")

        self.inf = ttk.Frame(self)
        self.inf.grid(row=1, column=1, sticky="nesw")

        self.ef = ttk.Frame(self, width=self.borderspan, style="Border.TFrame")
        self.ef.grid(row=1, column=2, sticky="nesw")

        self.swf = ttk.Frame(self, width=self.borderspan, height=self.borderspan, style="Border.TFrame")
        self.swf.grid(row=2, column=0, sticky="nesw")
        self.sf = ttk.Frame(self, height=self.borderspan, style="Border.TFrame")
        self.sf.grid(row=2, column=1, sticky="nesw")
        self.sef = ttk.Frame(self, width=self.borderspan, height=self.borderspan, style="Border.TFrame")
        self.sef.grid(row=2, column=2, sticky="nesw")

##################################################
项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, text="Pick A Colour", *args):
        ttk.Button.__init__(self, parent, text=text, command=self._pick_colour, *args)
        self.parent = parent
        self._text = text

        ttk.Style().configure("ColourButton.TButton")

        self.configure(style="ColourButton.TButton")
项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def _pick_colour(self):
        colour = askcolor()
        self.configure(text=colour[1])
        ttk.Style().configure("ColourButton.TButton", background=colour[1])
项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def reset(self):
        """Resets the button."""
        self.configure(text=self._text)
        ttk.Style().configure("ColourButton.TButton", background=ttk.Style().lookup("TButton", "background"))
项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, valid_list=[], *args):
        ttk.Entry.__init__(self, parent, *args)
        self.parent = parent
        self._valid_list = valid_list
        self._valid = False

        ttk.Style().configure("Valid.TEntry", foreground="green")
        ttk.Style().configure("NotValid.TEntry", foreground="red")

        self.configure(style="Valid.TEntry")
        self.bind("<KeyRelease>", self._check, "+")
项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, *args):
        ttk.Frame.__init__(self, parent, *args)
        self.parent = parent

        self.columnconfigure((0, 1), weight=1)

        self._button_variable = tk.BooleanVar()
        self._button_variable.set(False)

        self._label_variable = tk.BooleanVar()
        self._label_variable.set(True)

        self._label_text_variable = tk.StringVar()

        ttk.Style().configure("Switch.TLabel", background="white", foreground="light gray", anchor="center")
        ttk.Style().configure("Label.TLabel", background="light blue", foreground="white", anchor="center")

        self._button = ttk.Label(self, text="| | |", width=4, style="Switch.TLabel")
        self._button.bind("<Button-1>", self.switch, "+")

        self._label = ttk.Label(self, textvariable=self._label_text_variable, width=4, style="Label.TLabel")

        ttk.Style().configure("ButtonSwitch.TFrame", background="light blue")
        self.configure(style="ButtonSwitch.TFrame")

        self.switch()
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def setUp(self):
        self.style = ttk.Style()
项目:copycat    作者:LSaldyt    | 项目源码 | 文件源码
def __init__(self, title):
        self.root = tk.Tk()
        self.root.title(title)
        tk.Grid.rowconfigure(self.root, 0, weight=1)
        tk.Grid.columnconfigure(self.root, 0, weight=1)
        self.app = MainApplication(self.root)
        self.app.grid(row=0, column=0, sticky=tk.N+tk.S+tk.E+tk.W)

        configure_style(ttk.Style())
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def main():
    top = tk.Tk()
    s = ttk.Style()
    # ?????????classic??vista???Vista??.????????????????.
    # ?????,??ttk??????Tkinter????.??????,????????????????????????
    # ??,?????????,?????????
    s.theme_use("classic")
    tk.Button(top, text="old button").pack()
    ttk.Button(top, text="new button").pack()

    top.mainloop()
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def setUp(self):
        super().setUp()
        self.style = ttk.Style(self.root)
项目:repo    作者:austinHeisleyCook    | 项目源码 | 文件源码
def __init__(self):
        #setup environment
        self.Font = ["arial 16"]
        root.geometry("200x280")
        root.title("contact creator")
        ttk.Style().configure("TLabel", relief="raised",background="#0ff", font=self.Font)
        ttk.Style().configure("TEntry", relief="raised",background="#aff", font=self.Font)
        ttk.Style().configure("TButton", relief="raised", background="#aff", font=self.Font)
        self.flabel = ttk.Label(text="filename")
        self.flabel.pack(side="top")
        self.filename = ttk.Entry()
        self.filename.pack(side="top")
        self.contactname = ttk.Label(text="name")
        self.contactname.pack(side="top")
        self.name = ttk.Entry()
        self.name.pack()
        self.phonenumber = ttk.Label(text="phonenumber:") 
        self.phonenumber.pack(side="top")
        self.number = ttk.Entry()
        self.number.pack()
        self.Email = ttk.Label(text="email address")
        self.Email.pack(side="top")
        self.email = ttk.Entry()
        self.email.pack()
        self.Save = ttk.Button(text="save data", command=self.save)
        self.Save.pack(side="top")
项目:repo    作者:austinHeisleyCook    | 项目源码 | 文件源码
def __init__(self, frame):
        frame = Frame()
        frame.pack()
        root.title("pyeditor")
        ttk.Style().configure("Tframe", padding=10, width="10", relief="raised",  background="green")
        ttk.Style().configure("TButton", padding=10, relief="flat", background="red", foreground="red")
        self.fileName = StringVar()
        self.filename = ttk.Label(text="filename")
        self.filename.pack(fill="both")
        self.filen = ttk.Entry(textvariable=self.fileName, width="20")
        self.filen.pack(side="top")
        self.contentdisplay = ttk.Label(text="contents")
        self.contentdisplay.pack(fill="both", padx=19)
        self.contents = Text()
        self.contents.pack(fill="both")
        self.openfile = ttk.Button(text="open", command=self.fileopen)
        self.openfile.pack(side="left")
        self.save = ttk.Button(text="add content", command=self.save)
        self.save.pack(side="left")
        self.fullsave = ttk.Button(text="save", command=self.overwrite)
        self.fullsave.pack(side="left")
        self.Newfile = ttk.Button(text="new file", command=self.new)
        self.Newfile.pack(side="left")
        self.cleartext = ttk.Button(text="clear txt", command=self.clearfile)
        self.cleartext.pack(side="left")
        self.Speak = ttk.Button(text="speak text", command=self.textSpeak)
        self.Speak.pack(side="left")
        self.About = ttk.Button(text="about me", command=self.about)
        self.About.pack(side="left")
        self.Copy = ttk.Button(text="Copy text", command=self.copytext)
        self.Copy.pack(side="left")
        self.Copy = ttk.Button(text="Paste text", command=self.Pastetext)
        self.Copy.pack(side="left")
        self.webview = ttk.Button(text="web view", command=self.webview)
        self.webview.pack(side="left")
        self.search = ttk.Button(text="search", command=self.searchit)
        self.search.pack(side="left")
        self.Exit = ttk.Button(text="exit", command=self.Exitprogram)
        self.Exit.pack(side="left")
项目:keepass-menu    作者:frostidaho    | 项目源码 | 文件源码
def init_root(self):
        self.root = tk.Tk()
        s = ttk.Style()
        s.theme_use('clam')
        s.configure('.', font=FONT_SPEC)
        s.configure('TButton', padding=0)
        self.root.style = s
        self.style = s

        self.frame = ttk.Frame(self.root)
        self.frame.pack()

        self.root.bind("<Return>", self.get_text_n_close)
        self.root.bind("<Escape>", self.kill)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def setUp(self):
        super().setUp()
        self.style = ttk.Style(self.root)
项目:stash-scanner    作者:senuido    | 项目源码 | 文件源码
def __init__(self, master, kw_vals, default_text='Any', **kwargs):
        super().__init__(master, **kwargs)

        self.default_text = default_text
        self.kw_vals = kw_vals
        self.kw_vals_inv = dict(map(reversed, kw_vals.items()))

        ui_style = Style()
        ui_style.configure('MultiCombobox.TMenubutton', relief=RAISED, padding=3, anchor=CENTER)
        ui_style.layout('MultiCombobox.TMenubutton', _layout)
        self.config(style='MultiCombobox.TMenubutton')

        menu = Menu(self, tearoff=False,
                    activeforeground='SystemHighlightText', activebackground='SystemHighlight',
                    foreground='SystemWindowText', background='SystemWindow',
                    disabledforeground='SystemGrayText', bd=0, activeborderwidth=1)
        self.configure(menu=menu)

        self.any_var = BooleanVar(value=True)
        menu.add_checkbutton(label=default_text, variable=self.any_var,
                             onvalue=True, offvalue=False,
                             command=self.anySelected)

        self.choices = {}
        for i, choice in enumerate(kw_vals):
            self.choices[choice] = BooleanVar()
            # columnbreak = (i+1) % 4 == 0
            columnbreak = False
            menu.add_checkbutton(label=choice, variable=self.choices[choice],
                                 onvalue=True, offvalue=False, columnbreak=columnbreak,
                                 command=self.updateValue)
        self.updateValue()
项目:synthesizer    作者:irmen    | 项目源码 | 文件源码
def __init__(self, audio_source, master=None):
        self.lowest_level = -50
        super().__init__(master)
        self.master.title("Levels")

        self.pbvar_left = tk.IntVar()
        self.pbvar_right = tk.IntVar()
        pbstyle = ttk.Style()
        pbstyle.theme_use("classic")
        pbstyle.configure("green.Vertical.TProgressbar", troughcolor="gray", background="light green")
        pbstyle.configure("yellow.Vertical.TProgressbar", troughcolor="gray", background="yellow")
        pbstyle.configure("red.Vertical.TProgressbar", troughcolor="gray", background="orange")

        frame = tk.LabelFrame(self, text="Left")
        frame.pack(side=tk.LEFT)
        tk.Label(frame, text="dB").pack()
        self.pb_left = ttk.Progressbar(frame, orient=tk.VERTICAL, length=300, maximum=-self.lowest_level, variable=self.pbvar_left, mode='determinate', style='yellow.Vertical.TProgressbar')
        self.pb_left.pack()

        frame = tk.LabelFrame(self, text="Right")
        frame.pack(side=tk.LEFT)
        tk.Label(frame, text="dB").pack()
        self.pb_right = ttk.Progressbar(frame, orient=tk.VERTICAL, length=300, maximum=-self.lowest_level, variable=self.pbvar_right, mode='determinate', style='yellow.Vertical.TProgressbar')
        self.pb_right.pack()

        frame = tk.LabelFrame(self, text="Info")
        self.info = tk.Label(frame, text="", justify=tk.LEFT)
        frame.pack()
        self.info.pack(side=tk.TOP)
        self.pack()
        self.update_rate = 15   # lower this if you hear the sound crackle!
        self.open_audio_file(audio_source)
        self.after_idle(self.update)
项目:tkpf    作者:marczellm    | 项目源码 | 文件源码
def new_window(cls):
        if _windows:
            window = tk.Toplevel()
        else:
            window = tk.Tk()
            window.style = ttk.Style()
            if window.style.theme_use() == 'default' and 'clam' in window.style.theme_names():
                window.style.theme_use('clam')

        _windows.append(window)
        return window
项目:algo-trading-pipeline    作者:NeuralKnot    | 项目源码 | 文件源码
def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.configure(bg=BG_COLOR)
        self.pack(fill=tk.BOTH, expand=1)

        style = ttk.Style()
        style.configure('TButton', background=BG_COLOR, borderthickness=0, highlightthickness=0, width=10)

        p1 = tk.PanedWindow(self, orient=tk.VERTICAL, bg=BG_COLOR)
        p1.pack(fill=tk.BOTH, expand=1)

        p2 = tk.PanedWindow(p1, bg=BG_COLOR)
        p2.grid_columnconfigure(0, weight=1)
        p2.grid_columnconfigure(1, weight=1)
        p1.add(p2)

        control = tk.Frame(p2, bg=BG_COLOR)
        control.grid_rowconfigure(1, weight=1)
        pbutton = ttk.Button(control, text="Start", command=lambda: power())
        pbutton.grid(row=0, column=0)
        statsbutton = ttk.Button(control, text="Statistics", command=lambda: controller.show_frame(StatsPage))
        statsbutton.grid(row=1, column=0)
        control.grid(row=0, column=0)

        trades = tk.Frame(p2, bg=BG_COLOR)
        ltrades = tk.Label(trades, text="Trades", font=LARGE_FONT, bg=BG_COLOR, fg=FONT_COLOR)
        ltrades.pack(pady=15)
        tradescroll = tk.Scrollbar(trades, width=12)
        tradescroll.pack(side=tk.RIGHT, fill=tk.Y)
        tradelist = tk.Listbox(trades, width=80, height=20, yscrollcommand=tradescroll.set, bg=BG_ALT_COLOR, fg=FONT_ALT_COLOR, font=FONT, selectbackground="#404040")
        tradelist.pack(side=tk.BOTTOM, fill=tk.BOTH)
        self.tradelist = tradelist
        tradescroll.config(command=tradelist.yview)
        trades.grid(row=0, column=1)

        readout = tk.Frame(p1, bg=BG_COLOR)
        scrollbar = tk.Scrollbar(readout, width=12)
        scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
        treadout = tk.Text(readout, yscrollcommand=scrollbar.set, state=tk.DISABLED, highlightthickness=0, bg=BG_ALT_COLOR, fg=FONT_ALT_COLOR, font=("Menlo", 12))
        treadout.pack(side=tk.BOTTOM, fill=tk.BOTH)
        self.console = treadout
        scrollbar.config(command=treadout.yview)
        p1.add(readout, padx=20, pady=20)

        def power():
            if not self.running:
                controller.start()
                pbutton.configure(text="Quit")
                self.running = True
            else:
                controller.stop()
                pbutton.configure(text="Start")
                self.running = False
项目:modis    作者:Infraxion    | 项目源码 | 文件源码
def __init__(self, parent):
        """
        Create a new module frame and add it to the given parent.

        Args:
            parent: A tk or ttk object
        """

        super(ModuleFrame, self).__init__(parent)
        logger.debug("Initialising module tabs")

        # Setup styles
        style = ttk.Style()
        style.configure("Module.TFrame", background="white")

        self.module_buttons = {}
        self.current_button = None

        # Module view
        self.module_list = ttk.Frame(self, width=150, style="Module.TFrame")
        self.module_list.grid(column=0, row=0, padx=0, pady=0, sticky="W E N S")
        self.module_list.columnconfigure(0, weight=1)
        self.module_list.rowconfigure(0, weight=0)
        self.module_list.rowconfigure(1, weight=1)
        # Header
        header = tk.Label(self.module_list, text="Modules", bg="white", fg="#484848")
        header.grid(column=0, row=0, padx=0, pady=0, sticky="W E N")
        # Module selection list
        self.module_selection = ttk.Frame(self.module_list, style="Module.TFrame")
        self.module_selection.grid(column=0, row=1, padx=0, pady=0, sticky="W E N S")
        self.module_selection.columnconfigure(0, weight=1)
        # Module UI view
        self.module_ui = ttk.Frame(self)
        self.module_ui.grid(column=1, row=0, padx=0, pady=0, sticky="W E N S")
        self.module_ui.columnconfigure(0, weight=1)
        self.module_ui.rowconfigure(0, weight=1)

        self.clear_modules()

        # Configure stretch ratios
        self.columnconfigure(0, minsize=150)
        self.columnconfigure(1, weight=1)
        self.rowconfigure(0, weight=1)
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def __init__(self, master):
        super().__init__()

        self.title("Log")
        self.geometry("600x300")

        self.notebook = ttk.Notebook(self)
        self.tab_trees = {}

        style = ttk.Style()
        style.configure("Treeview", font=(None,12))
        style.configure("Treeview.Heading", font=(None, 14))

        dates = self.master.get_unique_dates()

        for index, date in enumerate(dates):
            dates[index] = date[0].split()[0]

        dates = sorted(set(dates), reverse=True)

        for date in dates:
            tab = tk.Frame(self.notebook)

            columns = ("name", "finished", "time")

            tree = ttk.Treeview(tab, columns=columns, show="headings")

            tree.heading("name", text="Name")
            tree.heading("finished", text="Full 25 Minutes")
            tree.heading("time", text="Time")

            tree.column("name", anchor="center")
            tree.column("finished", anchor="center")
            tree.column("time", anchor="center")

            tasks = self.master.get_tasks_by_date(date)

            for task_name, task_finished, task_date in tasks:
                task_finished_text = "Yes" if task_finished else "No"
                task_time = task_date.split()[1]
                task_time_pieces = task_time.split(":")
                task_time_pretty = "{}:{}".format(task_time_pieces[0], task_time_pieces[1])
                tree.insert("", tk.END, values=(task_name, task_finished_text, task_time_pretty))

            tree.pack(fill=tk.BOTH, expand=1)
            tree.bind("<Double-Button-1>", self.confirm_delete)
            self.tab_trees[date] = tree

            self.notebook.add(tab, text=date)

        self.notebook.pack(fill=tk.BOTH, expand=1)
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def __init__(self):
        super().__init__()

        self.title("Pomodoro Timer")
        self.geometry("500x300")
        self.resizable(False, False)

        style = ttk.Style()
        style.configure("TLabel", foreground="black", background="lightgrey", font=(None, 16), anchor="center")
        style.configure("B.TLabel", font=(None, 40))
        style.configure("B.TButton", foreground="black", background="lightgrey", font=(None, 16), anchor="center")
        style.configure("TEntry", foregound="black", background="white")

        self.menubar = tk.Menu(self, bg="lightgrey", fg="black")

        self.log_menu = tk.Menu(self.menubar, tearoff=0, bg="lightgrey", fg="black")
        self.log_menu.add_command(label="View Log", command=self.show_log_window, accelerator="Ctrl+L")

        self.menubar.add_cascade(label="Log", menu=self.log_menu)
        self.configure(menu=self.menubar)

        self.main_frame = tk.Frame(self, width=500, height=300, bg="lightgrey")

        self.task_name_label = ttk.Label(self.main_frame, text="Task Name:")
        self.task_name_entry = ttk.Entry(self.main_frame, font=(None, 16))
        self.start_button = ttk.Button(self.main_frame, text="Start", command=self.start, style="B.TButton")
        self.time_remaining_var = tk.StringVar(self.main_frame)
        self.time_remaining_var.set("25:00")
        self.time_remaining_label = ttk.Label(self.main_frame, textvar=self.time_remaining_var, style="B.TLabel")
        self.pause_button = ttk.Button(self.main_frame, text="Pause", command=self.pause, state="disabled", style="B.TButton")

        self.main_frame.pack(fill=tk.BOTH, expand=1)

        self.task_name_label.pack(fill=tk.X, pady=15)
        self.task_name_entry.pack(fill=tk.X, padx=50, pady=(0,20))
        self.start_button.pack(fill=tk.X, padx=50)
        self.time_remaining_label.pack(fill=tk.X ,pady=15)
        self.pause_button.pack(fill=tk.X, padx=50)

        self.bind("<Control-l>", self.show_log_window)

        self.protocol("WM_DELETE_WINDOW", self.safe_destroy)

        self.task_name_entry.focus_set()
项目:stash-scanner    作者:senuido    | 项目源码 | 文件源码
def __init__(self, master, determinate=True, *args, **kwargs):
        self._queue = queue.Queue()

        super().__init__(master, *args, **kwargs)
        self.withdraw()
        # if master.winfo_viewable():
        #     self.transient(master)
        # style = Style()
        # style.configure('LoadingScreen.TFrame', padding=0, bg='black')

        self.determinate = determinate
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        self.frm_border = Frame(self, borderwidth=2, relief=SOLID)
        self.frm_border.columnconfigure(0, weight=1)
        self.frm_border.rowconfigure(0, weight=1)
        self.frm_border.grid(sticky='nsew')

        self.frm = Frame(self.frm_border)
        self.frm.grid(row=0, column=0, padx=20, pady=20, sticky='nsew')
        self.lbl_info = Label(self.frm)
        self.frm.columnconfigure(0, weight=1, minsize=250)

        self.lbl_info.grid(row=0, column=0, sticky='ew')
        pb_mode = 'determinate' if self.determinate else 'indeterminate'
        self.pb_progress = Progressbar(self.frm, mode=pb_mode)
        self.pb_progress.grid(row=1, column=0, sticky='ew')

        self.update_idletasks()
        self.wm_overrideredirect(1)
        self.master.bind('<Configure>', self.updatePosition, add='+')
        self.updatePosition()

        self.deiconify()
        self.wait_visibility()
        self.grab_set()
        self.focus_set()

        if not self.determinate:
            # self.pb_progress.config(mode='determinate')
            self.pb_progress.start(10)

        self.after(10, self.processMessages)
项目:pyGISS    作者:afourmy    | 项目源码 | 文件源码
def __init__(self, path_app):
        super().__init__()
        self.title('Extended PyGISS')
        path_icon = abspath(join(path_app, pardir, 'images'))

        # generate the PSF tk images
        img_psf = ImageTk.Image.open(join(
                                          path_icon, 
                                          'node.png'
                                          )
                                    )

        selected_img_psf = ImageTk.Image.open(join(
                                          path_icon, 
                                          'selected_node.png'
                                          )
                                    )
        self.psf_button_image = ImageTk.PhotoImage(img_psf.resize((100, 100)))
        self.node_image = ImageTk.PhotoImage(img_psf.resize((40, 40)))
        self.selected_node_image = ImageTk.PhotoImage(selected_img_psf.resize((40, 40)))

        for widget in (
                       'Button',
                       'Label', 
                       'Labelframe', 
                       'Labelframe.Label', 
                       ):
            ttk.Style().configure('T' + widget, background='#A1DBCD')

        self.map = Map(self)
        self.map.pack(side='right', fill='both', expand=1)

        self.menu = Menu(self)
        self.menu.pack(side='right', fill='both', expand=1)

        menu = tk.Menu(self)
        menu.add_command(label="Import shapefile", command=self.map.import_map)
        self.config(menu=menu)

        # if motion is called, the left-click button was released and we 
        # can stop the drag and drop process
        self.bind_all('<Motion>', self.stop_drag_and_drop)
        self.drag_and_drop = False

        self.image = None
        self.bind_all('<B1-Motion>', lambda _:_)
项目:qcri    作者:douville    | 项目源码 | 文件源码
def __init__(self, cfg):
        tk.Tk.__init__(self)
        self.cfg = cfg  # ConfigParser

        self.qcc = None  # the Quality Center connection
        self.valid_parsers = {}
        self._cached_tests = {}  # for the treeview
        self._results = {}  # test results
        self.dir_dict = {}
        self.bug_dict = {}

        self.protocol("WM_DELETE_WINDOW", self.on_closing)
        self.title('QC Results Importer')
        center(self, 1200, 700)

        # tkinter widgets
        self.menubar = None
        self.remote_path = None
        self.choose_parser = None
        self.choose_results_button = None
        self.qcdir_tree = None
        self.upload_button = None
        self.choose_results_entry = None
        self.runresults_tree = None
        self.runresultsview = None
        self.header_frame = None
        self.qc_connected_frm = None
        self.qc_disconnected_frm = None
        self.link_bug = None

        self.qc_domain = tk.StringVar()
        self.attach_report = tk.IntVar()
        self.qc_project = tk.StringVar()
        self.runresultsvar = tk.StringVar()
        self.qc_conn_status = tk.BooleanVar()

        # build the gui        
        self._make()

        # style = ttk.Style()
        # style.theme_settings("default", {
        #     "TCombobox": {
        #         "configure": {"padding": 25}
        #     }
        # })