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

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

项目:python-tagger    作者:Bilingual-Annotation-Task-Force    | 项目源码 | 文件源码
def _create_widgets(self):
        # Gold standard data
        self.gold_path_label = ttk.Label(text="Gold Standard:")
        self.gold_path_entry = ttk.Entry(textvariable=self.gold_path)
        self.gold_path_filebutton = ttk.Button(text="...", command=self.findgoldfile)
        # Training data for language 1
        self.lang1_train_path_label = ttk.Label(text="Language 1 Training Data:")
        self.lang1_train_path_entry = ttk.Entry(textvariable=self.lang1_train_path)
        self.lang1_train_path_filebutton = ttk.Button(text="...", command=self.findlang1trainfile)
        # Training data for language 2
        self.lang2_train_path_label = ttk.Label(text="Language 2 Training Data:")
        self.lang2_train_path_entry = ttk.Entry(textvariable=self.lang2_train_path)
        self.lang2_train_path_filebutton = ttk.Button(text="...", command=self.findlang2trainfile)
        # Examination
        self.examine_button = ttk.Button(text="Examine!", command=self.launch_main)
        # Redirected ouput
        self.output_frame = ttk.Frame()
        self.output = tk.Text(master=self.output_frame)
        self.output_scroll = ttk.Scrollbar(self.output_frame)
        self.output.configure(yscrollcommand=self.output_scroll.set)
        self.output_scroll.configure(command=self.output.yview)

        self.redirected = Redirector(self.output)
项目: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()
项目:PyTasks    作者:TheHirschfield    | 项目源码 | 文件源码
def onNewTask(self):
        print("This Will Allow The User To Create An Task.")

        self.taskWindows = Toplevel(self)
        self.taskWindows.wm_title("New Task")

        Label(self.taskWindows, text="Task Name").grid(row=0)
        Label(self.taskWindows, text="Task Day:").grid(row=1)
        Label(self.taskWindows, text="Task Month:").grid(row=2)
        Label(self.taskWindows, text="Task Year:").grid(row=3)

        self.taskGrid1 = Entry(self.taskWindows)
        self.taskGrid2 = Entry(self.taskWindows)
        self.taskGrid3 = Entry(self.taskWindows)
        self.taskGrid4 = Entry(self.taskWindows)

        self.taskGrid1.grid(row=0, column=1)
        self.taskGrid2.grid(row=1, column=1)
        self.taskGrid3.grid(row=2, column=1)
        self.taskGrid4.grid(row=3, column=1)

        Button(self.taskWindows, text='Add', command=self.taskWindowAdd).grid(row=5, column=0, sticky=W, pady=4)
        Button(self.taskWindows, text='Cancel', command=self.taskWindowClose).grid(row=5, column=1, sticky=W, pady=4)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __init__(self, panedwindow, sash_index, disallow_dragging=False, on_click=None, **kw):
        image = kw.pop("image", None)
        Frame.__init__(self, panedwindow, class_="Handle", **kw)

        self._sash_index = sash_index

        if image:
            self._event_area = Label(self, image=image)
            self._event_area.pack()            
        else:
            self._event_area = self

        self._center = int(self._event_area.winfo_reqwidth()/2), int(self._event_area.winfo_reqheight()/2)

        if disallow_dragging:
            if on_click:
                self._event_area.bind('<Button-1>', lambda event: on_click())
        else:
            self._event_area.bind('<Button-1>', self._initiate_motion)
            self._event_area.bind('<B1-Motion>', self._on_dragging)
            self._event_area.bind('<ButtonRelease-1>', self.master._on_release)
项目:modis    作者:Infraxion    | 项目源码 | 文件源码
def __init__(self, parent):
        """
        Create a new status bar.

        Args:
            parent: A tk or ttk object
        """
        logger.debug("Initialising status bar")

        super(StatusBar, self).__init__(parent)

        self.status = tk.StringVar()
        # Status bar
        self.statusbar = ttk.Label(self, textvariable=self.status, padding=2, anchor="center")
        self.statusbar.grid(column=0, row=0, sticky="W E")

        # Configure stretch ratios
        self.columnconfigure(0, weight=1)

        # Set default status
        self.set_status(False)
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def show_tip(self, tip_text):
        "Display text in a tooltip window"
        if self.tip_window or not tip_text:
            return
        x, y, _cx, cy = self.widget.bbox("insert")      # get size of widget
        x = x + self.widget.winfo_rootx() + 25          # calculate to display tooltip 
        y = y + cy + self.widget.winfo_rooty() + 25     # below and to the right
        self.tip_window = tw = tk.Toplevel(self.widget) # create new tooltip window
        tw.wm_overrideredirect(True)                    # remove all Window Manager (wm) decorations
#         tw.wm_overrideredirect(False)                 # uncomment to see the effect
        tw.wm_geometry("+%d+%d" % (x, y))               # create window size

        label = tk.Label(tw, text=tip_text, justify=tk.LEFT,
                      background="#ffffe0", relief=tk.SOLID, borderwidth=1,
                      font=("tahoma", "8", "normal"))
        label.pack(ipadx=1)
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def tkinterApp():
    import tkinter as tk
    from tkinter import ttk
    win = tk.Tk()    
    win.title("Python GUI")
    aLabel = ttk.Label(win, text="A Label")
    aLabel.grid(column=0, row=0)    
    ttk.Label(win, text="Enter a name:").grid(column=0, row=0)
    name = tk.StringVar()
    nameEntered = ttk.Entry(win, width=12, textvariable=name)
    nameEntered.grid(column=0, row=1)
    nameEntered.focus() 

    def buttonCallback():
        action.configure(text='Hello ' + name.get())
    action = ttk.Button(win, text="Print", command=buttonCallback) 
    action.grid(column=2, row=1)
    win.mainloop()

#==================================================================
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def show_tip(self, tip_text):
        "Display text in a tooltip window"
        if self.tip_window or not tip_text:
            return
        x, y, _cx, cy = self.widget.bbox("insert")      # get size of widget
        x = x + self.widget.winfo_rootx() + 25          # calculate to display tooltip 
        y = y + cy + self.widget.winfo_rooty() + 25     # below and to the right
        self.tip_window = tw = tk.Toplevel(self.widget) # create new tooltip window
        tw.wm_overrideredirect(True)                    # remove all Window Manager (wm) decorations
#         tw.wm_overrideredirect(False)                 # uncomment to see the effect
        tw.wm_geometry("+%d+%d" % (x, y))               # create window size

        label = tk.Label(tw, text=tip_text, justify=tk.LEFT,
                      background="#ffffe0", relief=tk.SOLID, borderwidth=1,
                      font=("tahoma", "8", "normal"))
        label.pack(ipadx=1)
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def show_tip(self, tip_text):
        "Display text in a tooltip window"
        if self.tip_window or not tip_text:
            return
        x, y, _cx, cy = self.widget.bbox("insert")      # get size of widget
        x = x + self.widget.winfo_rootx() + 25          # calculate to display tooltip 
        y = y + cy + self.widget.winfo_rooty() + 25     # below and to the right
        self.tip_window = tw = tk.Toplevel(self.widget) # create new tooltip window
        tw.wm_overrideredirect(True)                    # remove all Window Manager (wm) decorations
#         tw.wm_overrideredirect(False)                 # uncomment to see the effect
        tw.wm_geometry("+%d+%d" % (x, y))               # create window size

        label = tk.Label(tw, text=tip_text, justify=tk.LEFT,
                      background="#ffffe0", relief=tk.SOLID, borderwidth=1,
                      font=("tahoma", "8", "normal"))
        label.pack(ipadx=1)
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def showtip(self, text):
        "Display text in a ToolTip window"
        self.text = text
        if self.tipwindow or not self.text: return
        try:
            x, y, _cx, cy = self.widget.bbox("insert")
            x = x + self.widget.winfo_rootx() + 25
            y = y + cy + self.widget.winfo_rooty() +25
            self.tipwindow = tw = tk.Toplevel(self.widget)
            tw.wm_overrideredirect(1)
            tw.wm_geometry("+%d+%d" % (x, y))
            label = tk.Label(tw, text=self.text, justify=tk.LEFT,
                          background="#ffffe0", relief=tk.SOLID, borderwidth=1,
                          font=("tahoma", "8", "normal"))
            label.pack(ipadx=1)
        except: pass
项目: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)
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def test_sashpos(self):
        self.assertRaises(tkinter.TclError, self.paned.sashpos, None)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, '')
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)

        child = ttk.Label(self.paned, text='a')
        self.paned.add(child, weight=1)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)
        child2 = ttk.Label(self.paned, text='b')
        self.paned.add(child2)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 1)

        self.paned.pack(expand=True, fill='both')
        self.paned.wait_visibility()

        curr_pos = self.paned.sashpos(0)
        self.paned.sashpos(0, 1000)
        self.assertNotEqual(curr_pos, self.paned.sashpos(0))
        self.assertIsInstance(self.paned.sashpos(0), int)
项目:Craft-Clash    作者:Derpyface-Development-Co    | 项目源码 | 文件源码
def test_sashpos(self):
        self.assertRaises(tkinter.TclError, self.paned.sashpos, None)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, '')
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)

        child = ttk.Label(self.paned, text='a')
        self.paned.add(child, weight=1)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)
        child2 = ttk.Label(self.paned, text='b')
        self.paned.add(child2)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 1)

        self.paned.pack(expand=True, fill='both')
        self.paned.wait_visibility()

        curr_pos = self.paned.sashpos(0)
        self.paned.sashpos(0, 1000)
        self.assertNotEqual(curr_pos, self.paned.sashpos(0))
        self.assertIsInstance(self.paned.sashpos(0), int)
项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, text="", link="https://github.com/DeflatedPickle/pkinter", *args):
        ttk.Label.__init__(self, parent, foreground="blue", cursor="arrow", *args)
        self.parent = parent
        self._text = text
        self._link = link

        self._font = font.Font(self, self.cget("font"))
        self.configure(font=self._font)

        if self._text == "":
            self.configure(text=self._link)

        else:
            self.configure(text=self._text)

        self.bind("<Enter>", self._enter, "+")
        self.bind("<Leave>", self._leave, "+")
        self.bind("<Button-1>", self._button, "+")
        self.bind("<ButtonRelease-1>", self._button_released, "+")
项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, text="Edit", does_resize=False, *args):
        ttk.Label.__init__(self, parent, *args)
        self.parent = parent
        self._text = text

        self._variable = tk.StringVar()
        self.configure(textvariable=self._variable)
        self._variable.set(self._text)

        self._entry = ttk.Entry(self, textvariable=self._variable)

        self.bind("<Double-Button-1>", self._edit, "+")
        self.bind("<Enter>", lambda: self.configure(cursor="hand2"), "+")
        self._entry.bind("<FocusOut>", self._confirm, "+")
        self._entry.bind("<Return>", self._confirm, "+")

        if does_resize:
            self._entry.bind("<Key>", self._resize)
            self._resize()

        self.configure(width=self._entry.cget("width"))
项目:ets2-telemetry-client-python    作者:roundowl    | 项目源码 | 文件源码
def createWidgets(self):
    #Configuration
    ttk.Label(root, text='Server IP').grid(row=0, column=0, sticky='news')
    ttk.Label(root, text='Interval (ms)').grid(row=0,column=1, sticky='news')
    ttk.Entry(root, textvariable=self.serverIP).grid(row=1,column=0,sticky='news')
    ttk.Entry(root, textvariable=self.interval).grid(row=1,column=1,sticky='news')
    #Buttons
    tk.Button(root, textvariable=self.connectedMessage, justify='center', command=self.connectToServer).\
      grid(row=2,column=0,columnspan=2,sticky='news')
    tk.Button(root, text='Open', justify='center', command=self.telematics.openFile).\
      grid(row=3,column=0,sticky='news')
    tk.Button(root, text='Save', justify='center', command=self.telematics.saveFile).\
      grid(row=3,column=1,sticky='news')
    #Variables
    r = 4
    for name, var in self.values.items():
      ttk.Label(root, text=name, width=20).grid(row=r,column=0)
      ttk.Label(root, textvariable=self.values[name], width=20).grid(row=r,column=1)
      r = r + 1
项目:skan    作者:jni    | 项目源码 | 文件源码
def create_parameters_frame(self, parent):
        parameters = ttk.Frame(master=parent, padding=STANDARD_MARGIN)
        parameters.grid(sticky='nsew')

        heading = ttk.Label(parameters, text='Analysis parameters')
        heading.grid(column=0, row=0, sticky='n')

        for i, param in enumerate(self.parameters, start=1):
            param_label = ttk.Label(parameters, text=param._name)
            param_label.grid(row=i, column=0, sticky='nsew')
            if type(param) == tk.BooleanVar:
                param_entry = ttk.Checkbutton(parameters, variable=param)
            elif hasattr(param, '_choices'):
                param_entry = ttk.OptionMenu(parameters, param, param.get(),
                                             *param._choices.keys())
            else:
                param_entry = ttk.Entry(parameters, textvariable=param)
            param_entry.grid(row=i, column=1, sticky='nsew')
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_sashpos(self):
        self.assertRaises(tkinter.TclError, self.paned.sashpos, None)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, '')
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)

        child = ttk.Label(self.paned, text='a')
        self.paned.add(child, weight=1)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)
        child2 = ttk.Label(self.paned, text='b')
        self.paned.add(child2)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 1)

        self.paned.pack(expand=True, fill='both')
        self.paned.wait_visibility()

        curr_pos = self.paned.sashpos(0)
        self.paned.sashpos(0, 1000)
        self.assertTrue(curr_pos != self.paned.sashpos(0))
        self.assertTrue(isinstance(self.paned.sashpos(0), int))
项目:ankimaker    作者:carllacan    | 项目源码 | 文件源码
def init_frame(self):
        self.dbfile = ''

        self.file_entry = ttk.Entry(self, width=25)
        self.file_entry.grid(column=0, row=1, columnspan=2, sticky='W')

        self.selecdb_button = ttk.Button(self, text='Browse',
                                      command=self.select_file)
        self.selecdb_button.grid(column=2, row=1, sticky='E')

        self.usage_check = CheckButton(self)
        self.usage_check.grid(column = 0, row = 2, sticky='E')
        self.usage_label = ttk.Label(self, text='Load also usage sentences')
        self.usage_label.grid(column = 1, row = 2, sticky='W')

        self.load_button = ttk.Button(self, text='Load words',
                                      command=self.load_words)
        self.load_button.grid(column = 2, row = 2, sticky='W')
项目:ankimaker    作者:carllacan    | 项目源码 | 文件源码
def init_frame(self):
        ttk.Label(self, text='App id').grid(column=0, row=0)
        self.appid_entry = ttk.Entry(self, width=30)
        self.appid_entry.grid(column=1, row = 0)

        ttk.Label(self, text='App key').grid(column=0, row=1)
        self.keyid_entry = ttk.Entry(self, width=30)
        self.keyid_entry.grid(column=1, row = 1)

        self.load_button = ttk.Button(self, text='Load definitions from OED',
                                      command=self.load_info)
        self.load_button.grid(column=0, row=2, columnspan = 2, rowspan = 2)
#        self.load_button.state(['disabled'])

        try: # for lazines I store my OED credentials in a file
            secrets = open('secrets')
            self.appid_entry.insert(0, secrets.readline()[:-1])
            self.keyid_entry.insert(0, secrets.readline()[:-1])
            secrets.close()
        except:
            pass
项目:playground    作者:CastalioPodcast    | 项目源码 | 文件源码
def __init__(self, master):
        tk.Frame.__init__(self, master)
        self.grid(column=0, row=0, sticky=(tk.W, tk.W, tk.E, tk.S))
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)
        self.master.title('Castalio Podcast')

        self.label = ttk.Label(self, text="")
        self.label.grid(column=0, row=0)

        self.tree = ttk.Treeview(self, columns=('date',))
        self.tree.heading('#1', text="Date")
        self.tree.insert('', 0, 'episodes', text='Episodes', open=True)
        self.tree.insert(
            'episodes',
            1,
            text='Episode 82',
            values=('Jan. 8, 2017',)
        )
        self.tree.grid(column=0, row=0, sticky=(tk.W, tk.W, tk.E, tk.S))

        self.pack(fill=tk.X)
项目:StochOPy    作者:keurfonluu    | 项目源码 | 文件源码
def de_widget(self):
        # Initialize widget
        self.init_widget()

        # strategy
        self.strategy_label = ttk.Label(self.frame1.sliders, text = "Strategy")
        self.strategy_option_menu = ttk.OptionMenu(self.frame1.sliders, self.strategy, self.strategy.get(),
                                                   *sorted(self.STRATOPT))
        self.strategy_label.place(relx = 0, x = 0, y = 5, anchor = "nw")
        self.strategy_option_menu.place(relx = 0, x = 70, y = 3, anchor = "nw")

        # CR
        self._label("Crossover probability", 2)
        self._scale(0., 1., 0.01, self.CR, 2)
        self._entry(self.CR, 2)

        # F
        self._label("Differential weight", 4)
        self._scale(0., 2., 0.01, self.F, 4)
        self._entry(self.F, 4)
项目:copycat    作者:LSaldyt    | 项目源码 | 文件源码
def __init__(self, parent, *args, **kwargs):
        GridFrame.__init__(self, parent, *args, **kwargs)
        self.aLabel = ttk.Label(self, text='Initial:')
        self.a      = ttk.Entry(self, style='EntryStyle.TEntry')

        self.add(self.aLabel, 0, 0)
        self.add(self.a, 0, 1)

        self.bLabel = ttk.Label(self, text='Final:')
        self.b      = ttk.Entry(self, style='EntryStyle.TEntry')

        self.add(self.bLabel, 1, 0)
        self.add(self.b, 1, 1)

        self.cLabel = ttk.Label(self, text='Next:')
        self.c      = ttk.Entry(self, style='EntryStyle.TEntry')

        self.add(self.cLabel, 2, 0)
        self.add(self.c, 2, 1)
        GridFrame.configure(self)
项目:pyktrader2    作者:harveywwu    | 项目源码 | 文件源码
def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="Graph Page!", font=LARGE_FONT)
        label.pack(pady=10,padx=10)

        button1 = ttk.Button(self, text="Back to Home",
                            command=lambda: controller.show_frame(StartPage))
        button1.pack()

        canvas = FigureCanvasTkAgg(f, self)
        canvas.show()
        canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)

        toolbar = NavigationToolbar2TkAgg(canvas, self)
        toolbar.update()
        canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def __init__(self, master):
        super().__init__()

        self.master = master

        self.title("Add new Language")
        self.geometry("300x150")

        self.name_label = ttk.Label(self, text="Language Name", anchor="center")
        self.name_entry = ttk.Entry(self)
        self.code_label = ttk.Label(self, text="Language Code", anchor="center")
        self.code_entry = ttk.Entry(self)
        self.submit_button = ttk.Button(self, text="Submit", command=self.submit)

        self.name_label.pack(fill=tk.BOTH, expand=1)
        self.name_entry.pack(fill=tk.BOTH)
        self.code_label.pack(fill=tk.BOTH, expand=1)
        self.code_entry.pack(fill=tk.BOTH, expand=1)
        self.submit_button.pack(fill=tk.X)
项目:chronophore    作者:mesbahamin    | 项目源码 | 文件源码
def _show_feedback_label(self, message, seconds=None):
        """Display a message in lbl_feedback, which then times out after
        some number of seconds. Use after() to schedule a callback to
        hide the feedback message. This works better than using threads,
        which can cause problems in Tk.
        """
        if seconds is None:
            seconds = CONFIG['MESSAGE_DURATION']

        # cancel any existing callback to clear the feedback
        # label. this prevents flickering and inconsistent
        # timing during rapid input.
        with contextlib.suppress(AttributeError):
            self.root.after_cancel(self.clear_feedback)

        logger.debug('Label feedback: "{}"'.format(message))
        self.feedback.set(message)
        self.clear_feedback = self.root.after(
            1000 * seconds, lambda: self.feedback.set("")
        )
项目:Colony    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, option, **kwargs):
        ttk.Frame.__init__(self, parent, **kwargs)
        self.parent = parent
        self.option = option

        # TODO: Add more options.

        ttk.Checkbutton(self, text="Debugging Mode", variable=self.option.variable_debug).grid(row=0, column=0, sticky="we")
        ttk.Checkbutton(self, text="Scrollbars", variable=self.option.variable_scrollbars).grid(row=1, column=0, sticky="we")
        ttk.Checkbutton(self, text="Grid", variable=self.option.variable_grid).grid(row=2, column=0, sticky="we")
        ttk.Checkbutton(self, text="Grid Highlight", variable=self.option.variable_grid_highlight).grid(row=3, column=0, sticky="we")

        frame_colour = ttk.Frame(self)
        ttk.Label(frame_colour, text="Highlight Colour").grid(row=0, column=0)
        ttk.Combobox(frame_colour, textvariable=self.option.variable_highlight_colour, values=["white", "red", "blue", "yellow", "green", "purple", "orange", "pink"], state="readonly", width=7).grid(row=0, column=1)
        frame_colour.grid(row=4, column=0, sticky="we")

        ttk.Checkbutton(self, text="Extra Speed Arrows", variable=self.option.variable_extra_speed_arrows).grid(row=5, column=0, sticky="we")
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_sashpos(self):
        self.assertRaises(tkinter.TclError, self.paned.sashpos, None)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, '')
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)

        child = ttk.Label(self.paned, text='a')
        self.paned.add(child, weight=1)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)
        child2 = ttk.Label(self.paned, text='b')
        self.paned.add(child2)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 1)

        self.paned.pack(expand=True, fill='both')
        self.paned.wait_visibility()

        curr_pos = self.paned.sashpos(0)
        self.paned.sashpos(0, 1000)
        self.assertNotEqual(curr_pos, self.paned.sashpos(0))
        self.assertIsInstance(self.paned.sashpos(0), int)
项目:schick-data-gui    作者:tuxor1337    | 项目源码 | 文件源码
def __init__(self, master, schick_reader):
        ttk.Frame.__init__(self, master)

        self.schick_reader = schick_reader
        self.index = self.schick_reader.vars

        self.v_name = StringVar()
        self.v_type = StringVar()

        lbl = ttk.Label(self, textvariable=self.v_name, font="bold")
        lbl2 = ttk.Label(self, textvariable=self.v_type)
        self.v_comment = Text(self, height=5, width=100)
        self.v_hex = Text(self, height=20, width=63, padx=10, pady=10)

        lbl.grid(column=0, row=0, padx=10, pady=5, sticky=(N,W))
        lbl2.grid(column=0, row=1, padx=10, pady=5, sticky=(N,W))
        self.v_comment.grid(column=0, row=2, padx=10, pady=5, sticky=(N,W))
        self.v_hex.grid(column=0, row=3, padx=10, pady=5, sticky=(N,S))
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(3, weight=1)

        self.v_name.set('')
        self.v_type.set('')
项目:schick-data-gui    作者:tuxor1337    | 项目源码 | 文件源码
def __init__(self, master, schick_reader):
        ttk.Frame.__init__(self, master)

        self.schick_reader = schick_reader
        self.index = ["Routes", "Travel events"]

        self.contents = {
            "Routes": SchickXRoutesContent(self, self.schick_reader),
            "Travel events": SchickXTEventsContent(self, self.schick_reader)
        }

        self.v_name = StringVar()
        self.content = None

        lbl = ttk.Label(self, textvariable=self.v_name, font="bold")

        lbl.grid(column=0, row=0, padx=10, pady=5, sticky=(N,W))
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(1, weight=1)

        self.v_name.set('')
项目:quill    作者:DeflatedPickle    | 项目源码 | 文件源码
def insert_ttk_label(self, anchor: tk.W or tk.CENTER or tk.E or str=None, background: str="", font: font.Font=None, foreground: str="", justify: tk.LEFT or tk.CENTER or tk.RIGHT or str=None, padding: list=[], relief: tk.FLAT or tk.RAISED or tk.SUNKEN or tk.GROOVE or tk.RIDGE or str="flat", text: str="", wraplength: int=0, index: int or str="end", *args, **kwargs):
        """Insert a ttk.Label into the game."""
        widget = ttk.Label(self.text, anchor=anchor, background=background, font=font, foreground=foreground, justify=justify, padding=padding, relief=relief, text=text, wraplength=wraplength, **kwargs)
        self.text.window_create(index, window=widget)

        return widget
项目:porcupine    作者:Akuli    | 项目源码 | 文件源码
def add_combobox(self, key, choices, text, *, case_sensitive=True):
        """Add a ``ttk.Combobox`` that sets an option to a string.

        The combobox will contain each string in *choices*.

        A `validator callback <Validating>`_ that ensures the value is
        in *choices* is also added. If *case_sensitive* is False,
        :meth:`str.casefold` is used when comparing the strings.
        """
        def validator(value):
            if case_sensitive:
                ok = (value in choices)
            else:
                ok = (value.casefold() in map(str.casefold, choices))
            if not ok:
                raise InvalidValue("%r is not a valid %r value"
                                   % (value, key))

        self.connect(key, validator)

        frame = self.add_frame(key)
        ttk.Label(frame, text=text).pack(side='left')
        ttk.Combobox(frame, values=choices,
                     textvariable=self.get_var(key)).pack(side='right')
项目:porcupine    作者:Akuli    | 项目源码 | 文件源码
def add_spinbox(self, key, minimum, maximum, text):
        """
        Add a :class:`utils.Spinbox <porcupine.utils.Spinbox>` that sets
        an option to an integer.

        The *minimum* and *maximum* arguments are used as the bounds for
        the spinbox. A `validator callback <Validating>`_ that makes
        sure the value is between them is also added.

        Note that *minimum* and *maximum* are inclusive, so
        ``minimum=3, maximum=5`` means that 3, 4 and 5 are valid values.
        """
        def validator(value):
            if value < minimum:
                raise InvalidValue("%r is too small" % value)
            if value > maximum:
                raise InvalidValue("%r is too big" % value)

        self.connect(key, validator)

        frame = self.add_frame(key)
        ttk.Label(frame, text=text).pack(side='left')
        utils.Spinbox(frame, textvariable=self.get_var(key, tkinter.IntVar),
                      from_=minimum, to=maximum).pack(side='right')
项目:porcupine    作者:Akuli    | 项目源码 | 文件源码
def make_please_wait_window(self):
        window = self.please_wait_window = tkinter.Toplevel()
        window.transient(porcupine.get_main_window())
        window.title("Pasting...")
        window.geometry('350x150')
        window.resizable(False, False)

        # disable the close button, there's no good way to cancel this
        # forcefully :(
        window.protocol('WM_DELETE_WINDOW', (lambda: None))

        content = ttk.Frame(window)
        content.pack(fill='both', expand=True)

        label = ttk.Label(
            content, font=('', 12, ''),
            text=("Pasting to %s, please wait..." % self.pastebin_name))
        label.pack(expand=True)

        progressbar = ttk.Progressbar(content, mode='indeterminate')
        progressbar.pack(fill='x', padx=15, pady=15)
        progressbar.start()
项目:PyTouch    作者:mNisblee    | 项目源码 | 文件源码
def __init__(self, master, title, main, sub, **kwargs):
        super().__init__(master=master, **kwargs)

        self.configure(borderwidth=3, relief='groove')

        self._title_font = font.Font(family='mono', size=-15)
        self._main_font = font.Font(family='mono', size=-30, weight='bold')
        self._sub_font = font.Font(family='mono', size=-15)

        self._title_string = StringVar(value=title)
        self._title_label = ttk.Label(self, textvariable=self._title_string, font=self._title_font)
        self._main_string = StringVar(value=main)
        self._main_label = ttk.Label(self, textvariable=self._main_string, font=self._main_font)
        self._sub_string = StringVar(value=sub)
        self._sub_label = ttk.Label(self, textvariable=self._sub_string, font=self._sub_font)

        self._title_label.grid(column=0, row=0, sticky=N + S + W, padx=15, pady=5)
        self._main_label.grid(column=0, row=1, sticky=N + S + W, padx=10, pady=5)
        self._sub_label.grid(column=0, row=2, sticky=N + S + W, padx=15, pady=5)

        self.columnconfigure(0, weight=1)
        self.rowconfigure(1, weight=1)
项目:PyTouch    作者:mNisblee    | 项目源码 | 文件源码
def __init__(self, master, **kwargs):
        super().__init__(master, **kwargs)

        self.content_frame = ttk.Frame(self)
        self.lb_title = ttk.Label(self.content_frame, text='Lesson paused')
        self.button_frame = ttk.Frame(self.content_frame)
        self.bt_continue = ttk.Button(self.button_frame, text='Continue', default='active', command=self.on_continue)
        self.bt_restart = ttk.Button(self.button_frame, text='Restart')
        self.bt_abort = ttk.Button(self.button_frame, text='Abort')

        self.content_frame.grid(column=0, row=0)
        self.lb_title.grid(column=0, row=0, pady=3)
        self.button_frame.grid(column=0, row=1, pady=10)
        self.bt_continue.grid(column=0, row=1, pady=3)
        self.bt_restart.grid(column=0, row=2, pady=3)
        self.bt_abort.grid(column=0, row=3, pady=3)

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

        self.focus_set()
项目:IC-Inventory    作者:tjschweizer    | 项目源码 | 文件源码
def invalidInventoryPopup(self, msg, *mainFuncs):
        """
        Creates a popupwindow and binds the button to multiple functions

        :param msg: Text message displayed in the popupwindow
        :type msg: str
        :param mainFuncs: List of functions to be run when the user clicks OK
        """
        window = Tk()
        window.wm_title('Invalid Inventory File')

        message = ttk.Label(window, text=msg)
        message.grid(row=0, column=0, columnspan=2, pady=10, padx=10, sticky=tkinter.N + tkinter.S)
        okButton = ttk.Button(window, text="OK", command=lambda: self.combine_funcs(window.destroy(), window.quit()))
        okButton.grid(row=1, column=1, sticky=tkinter.N + tkinter.S)
        window.mainloop()
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_sashpos(self):
        self.assertRaises(tkinter.TclError, self.paned.sashpos, None)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, '')
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)

        child = ttk.Label(self.paned, text='a')
        self.paned.add(child, weight=1)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)
        child2 = ttk.Label(self.paned, text='b')
        self.paned.add(child2)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 1)

        self.paned.pack(expand=True, fill='both')
        self.paned.wait_visibility()

        curr_pos = self.paned.sashpos(0)
        self.paned.sashpos(0, 1000)
        self.assertNotEqual(curr_pos, self.paned.sashpos(0))
        self.assertIsInstance(self.paned.sashpos(0), int)
项目: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))
项目:pyTrack    作者:clamytoe    | 项目源码 | 文件源码
def setup_tab2(tab):
    # new frame
    new_frame = ttk.LabelFrame(tab, text='New Project Name')
    new_frame.grid(columnspan=2, row=0, padx=5, pady=5, sticky='ew')

    # New Project
    name = tk.StringVar
    name_entered = ttk.Entry(new_frame, width=19, textvariable=name)
    name_entered.grid(column=0, row=0, padx=6, pady=5)
    name_entered.focus()

    # spacer
    spacer_label = ttk.Label(new_frame, text='')
    spacer_label.grid(columnspan=2, row=1, padx=5, pady=5)

    # add button and commands
    def add_command():
        add_project(name_entered.get())
        spacer_label.configure(text='Project was added!', foreground='green')
        name_entered.delete(0, "end")
        setup_tab1(TAB_1)
        TAB_1.update()

    add_button = ttk.Button(tab, text='Add New Project', command=add_command)
    add_button.grid(columnspan=2, row=3, pady=5)
项目:sorter    作者:giantas    | 项目源码 | 文件源码
def _show_history(self):
        history_window = self._create_window('History')
        history_window.resizable(height=False, width=False)
        history_window.geometry('{0}x{1}+{2}+{3}'.format(200, 90, 300, 150))

        history_label = ttk.Label(
            history_window, text='Enter number: ', background=self.bg)
        history_label.grid(row=0, column=0, padx=5, pady=5)

        history_entry = ttk.Entry(history_window, width=10)
        history_entry.grid(row=0, column=1, padx=5, pady=5)
        history_entry.focus_set()

        help_text = ttk.Label(history_window, text='Number of files (in history) to view.\n\nPress Enter when done.',
                              background=self.bg, foreground="#C0C0C0", anchor=CENTER, justify='center')
        help_text.grid(row=1, column=0, columnspan=2, padx=5, pady=5)
        history_window.bind('<Return>',
                            lambda event, entry_widget=history_entry, window=history_window: self._evaluate(event, entry_widget, window))
        history_window.bind('<KP_Enter>',
                            lambda event, entry_widget=history_entry, window=history_window: self._evaluate(event, entry_widget, window))
项目:pysaf    作者:cstarcher    | 项目源码 | 文件源码
def restrict_access_button(self, gs):
        """Expand frame to reveal options when Restrict Read Access is selected."""
        if self.access_button_var.get() == 1:
            self.group_name_label = ttk.Label(self.access_frame,
                                              width=20,
                                              anchor=tk.E,
                                              text='Group Name ')
            self.group_name_label.grid(row=2, column=0, sticky='e')
            self.group_name_label.grid_configure(pady=5)
            self.group_name_var = tk.StringVar()
            self.group_name_entry = ttk.Entry(self.access_frame,
                                              width=20,
                                              textvariable=self.group_name_var)
            self.group_name_entry.grid(row=2, column=1, sticky='w')
            self.group_name_entry.grid_configure(pady=5)
            self.group_name_var.set('member')
        else:
            self.group_name_label.destroy()
            self.group_name_entry.destroy()
项目:pysaf    作者:cstarcher    | 项目源码 | 文件源码
def restrict_access_button(self, gs):
        """Expand frame to reveal options when Restrict Read Access is selected."""
        if self.access_button_var.get() == 1:
            self.group_name_label = ttk.Label(self.access_frame,
                                              width=15,
                                              anchor=tk.E,
                                              text='Group Name ')
            self.group_name_label.grid(row=2, column=0, sticky='e')
            self.group_name_label.grid_configure(pady=5)
            self.group_name_var = tk.StringVar()
            self.group_name_entry = ttk.Entry(self.access_frame,
                                              width=15,
                                              textvariable=self.group_name_var)
            self.group_name_entry.grid(row=2, column=1, sticky='w')
            self.group_name_entry.grid_configure(pady=5)
            self.group_name_var.set('member')
        else:
            self.group_name_label.destroy()
            self.group_name_entry.destroy()
项目:PyTasks    作者:TheHirschfield    | 项目源码 | 文件源码
def calenderPlaceWidget(self):
        #Header Frame
        calenderFrame = ttk.Frame(self)
        leftMonthChangeButton = ttk.Button(calenderFrame, style='L.TButton', command=self.setPreviousMonth)
        rightMonthChangeButton = ttk.Button(calenderFrame, style='R.TButton', command=self.setNextMonth)
        self.calenderHeader = ttk.Label(calenderFrame, width=15, anchor='center')
        self.calenderMainView = ttk.Treeview(show='', selectmode='none', height=7, style='Calendar.Treeview')

        #Pack Header
        calenderFrame.pack(in_=self, side='top', pady=4, anchor='center')
        leftMonthChangeButton.grid(in_=calenderFrame)
        self.calenderHeader.grid(in_=calenderFrame, column=1, row=0, padx=12)
        rightMonthChangeButton.grid(in_=calenderFrame, column=2, row=0)
        self.calenderMainView.pack(in_=self, fill='x', side='top')
项目:modis    作者:Infraxion    | 项目源码 | 文件源码
def __init__(self, parent):
        """Send messages from the bot

        Args:
            parent:
        """

        super(ChatFrame, self).__init__(parent, padding=8, text="Chat")

        self.channel = tk.StringVar()
        self.message = tk.StringVar()

        self.channel_frame = ttk.Frame(self)
        self.channel_frame.grid(column=0, row=0, sticky="W E")
        self.channel_label = ttk.Label(self.channel_frame, text="Channel ID:")
        self.channel_label.grid(column=0, row=0, sticky="W E")
        self.channel_box = ttk.Entry(self.channel_frame, textvariable=self.channel)
        self.channel_box.grid(column=0, row=1, sticky="W E")
        self.channel_frame.columnconfigure(0, weight=1)

        self.message_frame = ttk.Frame(self)
        self.message_frame.grid(column=0, row=1, pady=8, sticky="W E")
        self.message_label = ttk.Label(self.message_frame, text="Message:")
        self.message_label.grid(column=0, row=0, sticky="W E")
        self.message_box = ttk.Entry(self.message_frame, textvariable=self.message)
        self.message_box.grid(column=0, row=1, sticky="W E")
        self.message_frame.columnconfigure(0, weight=1)

        self.send_button = ttk.Button(self, command=lambda: self.add_current_message(), text="Send")
        self.send_button.grid(column=0, row=2, sticky="W")

        self.columnconfigure(0, weight=1)
项目:modis    作者:Infraxion    | 项目源码 | 文件源码
def __init__(self, parent):
        """
        Create a new UI for the module

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

        super(ModuleUIFrame, self).__init__(parent)
        self.columnconfigure(0, weight=1)
        self.rowconfigure(1, weight=1)

        # Set default values
        from ....datatools import get_data
        data = get_data()

        # API Frame
        api_frame = ttk.LabelFrame(self, padding=8, text="Google API")
        api_frame.grid(row=0, column=0, sticky="W E N S")
        api_frame.columnconfigure(0, weight=1)
        # Add key fields
        self.google_api_key = tk.StringVar()
        ttk.Label(api_frame, text="Google API Key").grid(column=0, row=0, sticky="W E N S")
        ttk.Entry(api_frame, textvariable=self.google_api_key).grid(
            column=0, row=1, padx=0, pady=4, sticky="W E N S")
        self.soundcloud_client_id = tk.StringVar()
        ttk.Label(api_frame, text="SoundCloud Client ID").grid(column=0, row=2, sticky="W E N S")
        ttk.Entry(api_frame, textvariable=self.soundcloud_client_id).grid(
            column=0, row=3, padx=0, pady=4, sticky="W E N S")
        ttk.Button(api_frame, command=lambda: self.update_keys(), text="Update API Data").grid(
            column=0, row=4, padx=0, pady=4, sticky="W E N S")

        if "google_api_key" in data["discord"]["keys"]:
            self.google_api_key.set(data["discord"]["keys"]["google_api_key"])
        if "soundcloud_client_id" in data["discord"]["keys"]:
            self.soundcloud_client_id.set(data["discord"]["keys"]["soundcloud_client_id"])
项目:modis    作者:Infraxion    | 项目源码 | 文件源码
def clear_modules(self):
        """Clears all modules from the list"""
        for child in self.module_selection.winfo_children():
            child.destroy()

        self.clear_ui()

        tk.Label(self.module_ui, text="Start Modis and select a module").grid(
            column=0, row=0, padx=0, pady=0, sticky="W E N S")

        if self.current_button is not None:
            self.current_button.config(bg="white")

        self.module_buttons = {}
        self.current_button = None
项目:modis    作者:Infraxion    | 项目源码 | 文件源码
def module_selected(self, module_name, module_ui):
        """
        Called when a module is selected

        Args:
            module_name (str): The name of the module
            module_ui: The function to call to create the module's UI
        """
        if self.current_button == self.module_buttons[module_name]:
            return

        self.module_buttons[module_name].config(bg="#cacaca")
        if self.current_button is not None:
            self.current_button.config(bg="white")
        self.current_button = self.module_buttons[module_name]

        self.clear_ui()

        try:
            # Create the UI
            module_ui_frame = ModuleUIBaseFrame(self.module_ui, module_name, module_ui)
            module_ui_frame.grid(column=0, row=0, sticky="W E N S")
        except Exception as e:
            logger.error("Could not load UI for {}".format(module_name))
            logger.exception(e)
            # Create a error UI
            tk.Label(self.module_ui, text="Could not load UI for {}".format(module_name)).grid(
                column=0, row=0, padx=0, pady=0, sticky="W E N S")
项目:modis    作者:Infraxion    | 项目源码 | 文件源码
def __init__(self, parent, module_name, module_ui):
        """
        Create a new base for a module UI

        Args:
            parent: A tk or ttk object
            module_name (str): The name of the module
            module_ui: The _ui.py file to add for the module
        """

        super(ModuleUIBaseFrame, self).__init__(parent, padding=8)
        self.columnconfigure(0, weight=1)
        self.rowconfigure(1, weight=1)

        if module_ui is not None:
            # Module UI frame
            module_ui.ModuleUIFrame(self).grid(row=0, column=0, sticky="W E N S")
        else:
            logger.debug("No _ui.py found for '{}'".format(module_name))

        # Help frame
        help_frame = ttk.LabelFrame(self, padding=8, text="Help")
        help_frame.grid(row=1, column=0, sticky="W E N S")
        help_frame.columnconfigure(0, weight=1)
        help_frame.rowconfigure(0, weight=1)
        # Find the help path
        _dir = os.path.realpath(
            os.path.join(os.getcwd(), os.path.dirname(__file__)))
        help_path = "{}/modules/{}/{}".format(_dir, module_name, "_help.json")
        if os.path.isfile(help_path):
            # Load the text
            helptools.add_help_text(help_frame, help_path)
        else:
            # Default message
            tk.Label(help_frame, text="No _help.json file found for '{}'".format(module_name)).grid(row=0, column=0,
                                                                                                    sticky="W E N S")