python类Style()的实例源码

test_style.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def setUp(self):
        super().setUp()
        self.style = ttk.Style(self.root)
MultiCombobox.py 文件源码 项目:stash-scanner 作者: senuido 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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()
soundplayer.py 文件源码 项目:synthesizer 作者: irmen 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)
Window.py 文件源码 项目:tkpf 作者: marczellm 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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
page.py 文件源码 项目:algo-trading-pipeline 作者: NeuralKnot 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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
gui.py 文件源码 项目:modis 作者: Infraxion 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
Chapter7-3.py 文件源码 项目:Tkinter-By-Example 作者: Dvlv 项目源码 文件源码 阅读 49 收藏 0 点赞 0 评论 0
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)
Chapter7-3.py 文件源码 项目:Tkinter-By-Example 作者: Dvlv 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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()
LoadingScreen.py 文件源码 项目:stash-scanner 作者: senuido 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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)
extended_pyGISS.py 文件源码 项目:pyGISS 作者: afourmy 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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 _:_)
gui.py 文件源码 项目:qcri 作者: douville 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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}
        #     }
        # })


问题


面经


文章

微信
公众号

扫码关注公众号