python类Label()的实例源码

eval_gui.py 文件源码 项目:python-tagger 作者: Bilingual-Annotation-Task-Force 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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)
box.py 文件源码 项目:synthesizer 作者: irmen 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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()
GUI.py 文件源码 项目:PyTasks 作者: TheHirschfield 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
recipe-580728.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
gui.py 文件源码 项目:modis 作者: Infraxion 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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)
GUI_OOP_2_classes.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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)
Embed_tkinter.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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()

#==================================================================
GUI_canvas.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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)
GUI_tooltip.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)
GUI_FallDown.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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
dialog.py 文件源码 项目:Quiver 作者: DeflatedPickle 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
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)
test_widgets.py 文件源码 项目:Craft-Clash 作者: Derpyface-Development-Co 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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)
test_widgets.py 文件源码 项目:Craft-Clash 作者: Derpyface-Development-Co 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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)
hyperlink.py 文件源码 项目:pkinter 作者: DeflatedPickle 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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, "+")
editablelabel.py 文件源码 项目:pkinter 作者: DeflatedPickle 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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"))
telemetry_app.py 文件源码 项目:ets2-telemetry-client-python 作者: roundowl 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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
gui.py 文件源码 项目:skan 作者: jni 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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')
test_widgets.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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))
kindleloader.py 文件源码 项目:ankimaker 作者: carllacan 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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')
oedloader.py 文件源码 项目:ankimaker 作者: carllacan 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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
tkcastalio.py 文件源码 项目:playground 作者: CastalioPodcast 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)
gui.py 文件源码 项目:StochOPy 作者: keurfonluu 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)
entry.py 文件源码 项目:copycat 作者: LSaldyt 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
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)
candle_tkgui_example.py 文件源码 项目:pyktrader2 作者: harveywwu 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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)
Chapter3-3-ttk.py 文件源码 项目:Tkinter-By-Example 作者: Dvlv 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)
tkview.py 文件源码 项目:chronophore 作者: mesbahamin 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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("")
        )
references.py 文件源码 项目:Colony 作者: DeflatedPickle 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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")
test_widgets.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)
exe.py 文件源码 项目:schick-data-gui 作者: tuxor1337 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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('')
extra.py 文件源码 项目:schick-data-gui 作者: tuxor1337 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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('')


问题


面经


文章

微信
公众号

扫码关注公众号