当前位置: 首页>>代码示例>>Python>>正文


Python Entry.pack方法代码示例

本文整理汇总了Python中tkinter.ttk.Entry.pack方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.pack方法的具体用法?Python Entry.pack怎么用?Python Entry.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter.ttk.Entry的用法示例。


在下文中一共展示了Entry.pack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DateWidget

# 需要导入模块: from tkinter.ttk import Entry [as 别名]
# 或者: from tkinter.ttk.Entry import pack [as 别名]
 class DateWidget(Frame):
     """Gets a date from the user."""
     def __init__(self, master):
         """Make boxes, register callbacks etc."""
         Frame.__init__(self, master)
         self.label = Label(self, text="När är du född?")
         self.label.pack()
         self.entry_text = StringVar()
         self.entry_text.trace("w", lambda *args: self.onEntryChanged())
         self.entry = Entry(self, width=date_entry_width,
              textvariable=self.entry_text)
         self.entry.insert(0, "ÅÅÅÅ-MM-DD")
         self.entry.pack(pady=small_pad)
         self.button = Button(self, text="Uppdatera",
              command=lambda: self.onDateChanged())
         self.button.pack()
         self.entry.focus_set()
         self.entry.select_range(0, END)
         self.entry.bind("<Return>", lambda x: self.onDateChanged())
     def setListener(self, pred_view):
         """Select whom to notify when a new date is entered."""
         self.pred_view = pred_view
     def onDateChanged(self):
         """Notifies the PredictionWidget that the date has been changed."""
         try:
             date = datetime.datetime.strptime(self.entry.get(),
                  "%Y-%m-%d").date()
             self.pred_view.update(date)
         except ValueError:
             self.entry.configure(foreground="red")
     def onEntryChanged(self):
         """Reset the text color."""
         self.entry.configure(foreground="")
开发者ID:JoelSjogren,项目名称:horoskop,代码行数:35,代码来源:main.py

示例2: add_entry

# 需要导入模块: from tkinter.ttk import Entry [as 别名]
# 或者: from tkinter.ttk.Entry import pack [as 别名]
 def add_entry(self, text):
     entry = Entry(self)
     entry.insert(0, ",".join(text))
     entry.pack(fill="both", expand=True)
     entry.config(state="readonly")
     self.bindings(entry)
     self.entries.append(entry)
开发者ID:Exodus111,项目名称:Projects,代码行数:9,代码来源:mod_items.py

示例3: Form

# 需要导入模块: from tkinter.ttk import Entry [as 别名]
# 或者: from tkinter.ttk.Entry import pack [as 别名]
class Form(Frame):
  
    def __init__(self, parent):
        Frame.__init__(self, parent)   
         
        self.parent = parent

        self.parent.title("Example Form")
        self.pack(fill=BOTH, expand=True)

        f = Frame(self)
        f.pack(fill=X)

        l = Label(f, text='First Name', width=10)
        l.pack(side=LEFT, padx=5, pady=5)
       
        self.firstName = Entry(f)
        self.firstName.pack(fill=X, padx=5, expand=True)
        
        f = Frame(self)
        f.pack(fill=X)
        
        l = Label(f, text='Last Name', width=10)
        l.pack(side=LEFT, padx=5, pady=5)

        self.lastName = Entry(f)
        self.lastName.pack(fill=X, padx=5, expand=True)
        
        f = Frame(self)
        f.pack(fill=X)

        l = Label(f, text='Full Name', width=10)
        l.pack(side=LEFT, padx=5, pady=5)

        self.fullName = Label(f, text='ALEX POOPKIN', width=10)
        self.fullName.pack(fill=X, padx=5, expand=True)

        f = Frame(self)
        f.pack(fill=X)

        l = Label(f, text='', width=10)
        l.pack(side=LEFT, padx=5, pady=0)

        self.errorMessage = Label(f, text='Invalid character int the name!', foreground='red', width=30)
        self.errorMessage.pack(fill=X, padx=5, expand=True)

        f = Frame(self)
        f.pack(fill=X)

        b = Button(f, text='Close', command=lambda : self.parent.quit())
        b.pack(side=RIGHT, padx=5, pady=10)
        b['default'] = ACTIVE
        b.focus_set()

        self.clearButton = Button(f, text='Clear')
        self.clearButton.pack(side=RIGHT, padx=5, pady=10)
        self.clearButton['state'] = DISABLED

        self.sendButton = Button(f, text='Send')
        self.sendButton.pack(side=RIGHT, padx=5, pady=10)
开发者ID:alex-kooper,项目名称:knockouttk,代码行数:62,代码来源:form.py

示例4: insert_entry_field

# 需要导入模块: from tkinter.ttk import Entry [as 别名]
# 或者: from tkinter.ttk.Entry import pack [as 别名]
 def insert_entry_field(self, txt):
     frame = Frame(self.frame)
     frame.pack(fill="x")
     label = Label(frame, text=txt, width=6)
     label.pack(side="left", anchor="n", padx=5, pady=5)
     entry = Entry(frame)
     entry.pack(fill="x", padx=5, pady=5, expand=True)
     self.entries["Entry"][txt] = entry
开发者ID:Exodus111,项目名称:Projects,代码行数:10,代码来源:main.py

示例5: Main

# 需要导入模块: from tkinter.ttk import Entry [as 别名]
# 或者: from tkinter.ttk.Entry import pack [as 别名]
class Main(Frame):
    """Main class for our browser.
        Note that we inherit from Frame, making this a Frame object.
    """
    def __init__(self, master):
        Frame.__init__(self, master)
        self.master = master
        self.master.title("Browser")
        self.header = {"User-Agent":"Tkinter Browser 0.1"}

        # Here we make our widgets.
        self.top_frame = Frame(self)
        self.url_frame = Frame(self.top_frame)
        self.url_label = Label(self.url_frame, text="Url: ", anchor="n")
        self.url_entry = Entry(self.url_frame, width=80)
        self.url_button = Button(self.url_frame, text="Go", command=self.go_button)
        self.bottom_frame = Frame(self)
        self.text_field = Text(self.bottom_frame)

        #Here we pack our widgets.
        self.top_frame.pack(side="top", padx=15, pady=15)
        self.url_frame.pack(anchor="center")
        self.bottom_frame.pack(side="bottom", fill="both", expand=True)
        self.text_field.pack(side="bottom", fill="both", expand=True)
        self.url_label.pack(side="left")
        self.url_entry.pack(side="left", fill="x", expand=True)
        self.url_button.pack(side="left", padx=5)
        self.text_field.config(state="disabled", padx=5, pady=5)

    def go_button(self):
        url = self.url_entry.get()
        if url:
            if "http://" not in url:
                url = "http://"+url
            page_text = self.get_page(url)
            self.text_field.config(state="normal")
            self.text_field.delete(1.0, "end")
            self.text_field.insert("end", page_text)
            self.text_field.config(state="disable")

    def get_page(self, url):
        s = requests.Session()
        resp = s.get(url, headers=self.header)
        data = resp.text
        soup = bs(data, "html.parser")
        page_text = soup.find_all(text=True)
        page_text = filter(self.visible, page_text)
        return "".join([str(i)+'\n' for i in page_text])


    def visible(self, e):
        if e.parent.name in ('style', 'script', '[document]', 'head', 'title'):
            return False
        elif re.match('<!--.*-->', str(e.encode('utf-8'))):
            return False
        return True
开发者ID:Exodus111,项目名称:Projects,代码行数:58,代码来源:browser.py

示例6: insert_entry_field

# 需要导入模块: from tkinter.ttk import Entry [as 别名]
# 或者: from tkinter.ttk.Entry import pack [as 别名]
 def insert_entry_field(self, txt, default=None, focus=False):
     frame = Frame(self.frame)
     frame.pack(fill="x")
     label = Label(frame, text=txt, width=6)
     label.pack(side="left", anchor="n", padx=5, pady=5)
     entry = Entry(frame)
     entry.pack(fill="x", padx=5, pady=5, expand=True)
     if default:
         entry.insert("end", default)
     if focus:
         entry.focus_force()
     self.entries["Entry"][txt] = entry
开发者ID:Exodus111,项目名称:Projects,代码行数:14,代码来源:load.py

示例7: initialize_ui

# 需要导入模块: from tkinter.ttk import Entry [as 别名]
# 或者: from tkinter.ttk.Entry import pack [as 别名]
 def initialize_ui(self):
   default_padding = {'padx': 10, 'pady' : 10}
   
   labels = ["Name", "Surname", "Email",  "Cellphone"]
   for label in labels:
     frame = Frame(self)
     Label(frame, text = label, style="BW.TLabel").pack(default_padding, side = LEFT)
     entry = Entry(frame)
     entry.pack(default_padding, side = RIGHT)
     self.entries.append(entry)
     frame.pack(expand = True, fill = "x", side = TOP)
     
   button_frame = Frame(self)
   Button(button_frame, text = "Create Customer", command =  self.save_customer).pack(default_padding)
   button_frame.pack(expand = True, fill = "x")
开发者ID:khlumzeemee,项目名称:3dprinter,代码行数:17,代码来源:ApplicationMVC.py

示例8: GetKeysDialog

# 需要导入模块: from tkinter.ttk import Entry [as 别名]
# 或者: from tkinter.ttk.Entry import pack [as 别名]
class GetKeysDialog(Toplevel):

    # Dialog title for invalid key sequence
    keyerror_title = 'Key Sequence Error'

    def __init__(self, parent, title, action, current_key_sequences,
                 *, _htest=False, _utest=False):
        """
        parent - parent of this dialog
        title - string which is the title of the popup dialog
        action - string, the name of the virtual event these keys will be
                 mapped to
        current_key_sequences - list, a list of all key sequence lists
                 currently mapped to virtual events, for overlap checking
        _htest - bool, change box location when running htest
        _utest - bool, do not wait when running unittest
        """
        Toplevel.__init__(self, parent)
        self.withdraw()  # Hide while setting geometry.
        self.configure(borderwidth=5)
        self.resizable(height=False, width=False)
        self.title(title)
        self.transient(parent)
        self.grab_set()
        self.protocol("WM_DELETE_WINDOW", self.cancel)
        self.parent = parent
        self.action = action
        self.current_key_sequences = current_key_sequences
        self.result = ''
        self.key_string = StringVar(self)
        self.key_string.set('')
        # Set self.modifiers, self.modifier_label.
        self.set_modifiers_for_platform()
        self.modifier_vars = []
        for modifier in self.modifiers:
            variable = StringVar(self)
            variable.set('')
            self.modifier_vars.append(variable)
        self.advanced = False
        self.create_widgets()
        self.update_idletasks()
        self.geometry(
                "+%d+%d" % (
                    parent.winfo_rootx() +
                    (parent.winfo_width()/2 - self.winfo_reqwidth()/2),
                    parent.winfo_rooty() +
                    ((parent.winfo_height()/2 - self.winfo_reqheight()/2)
                    if not _htest else 150)
                ) )  # Center dialog over parent (or below htest box).
        if not _utest:
            self.deiconify()  # Geometry set, unhide.
            self.wait_window()

    def showerror(self, *args, **kwargs):
        # Make testing easier.  Replace in #30751.
        messagebox.showerror(*args, **kwargs)

    def create_widgets(self):
        self.frame = frame = Frame(self, borderwidth=2, relief='sunken')
        frame.pack(side='top', expand=True, fill='both')

        frame_buttons = Frame(self)
        frame_buttons.pack(side='bottom', fill='x')

        self.button_ok = Button(frame_buttons, text='OK',
                                width=8, command=self.ok)
        self.button_ok.grid(row=0, column=0, padx=5, pady=5)
        self.button_cancel = Button(frame_buttons, text='Cancel',
                                   width=8, command=self.cancel)
        self.button_cancel.grid(row=0, column=1, padx=5, pady=5)

        # Basic entry key sequence.
        self.frame_keyseq_basic = Frame(frame, name='keyseq_basic')
        self.frame_keyseq_basic.grid(row=0, column=0, sticky='nsew',
                                      padx=5, pady=5)
        basic_title = Label(self.frame_keyseq_basic,
                            text=f"New keys for '{self.action}' :")
        basic_title.pack(anchor='w')

        basic_keys = Label(self.frame_keyseq_basic, justify='left',
                           textvariable=self.key_string, relief='groove',
                           borderwidth=2)
        basic_keys.pack(ipadx=5, ipady=5, fill='x')

        # Basic entry controls.
        self.frame_controls_basic = Frame(frame)
        self.frame_controls_basic.grid(row=1, column=0, sticky='nsew', padx=5)

        # Basic entry modifiers.
        self.modifier_checkbuttons = {}
        column = 0
        for modifier, variable in zip(self.modifiers, self.modifier_vars):
            label = self.modifier_label.get(modifier, modifier)
            check = Checkbutton(self.frame_controls_basic,
                                command=self.build_key_string, text=label,
                                variable=variable, onvalue=modifier, offvalue='')
            check.grid(row=0, column=column, padx=2, sticky='w')
            self.modifier_checkbuttons[modifier] = check
            column += 1

#.........这里部分代码省略.........
开发者ID:Eyepea,项目名称:cpython,代码行数:103,代码来源:config_key.py

示例9: __init__

# 需要导入模块: from tkinter.ttk import Entry [as 别名]
# 或者: from tkinter.ttk.Entry import pack [as 别名]
    def __init__(self, parent):
        super().__init__(parent)
        self.parent = parent

        self.parent.title("InstaDjango")

        self.pack(fill=BOTH, expand=1)
        self.size_and_center_window()

        self.style = Style()
        self.style.theme_use("clam")
        self.style.configure("TFrame", background="#808080", foreground="white")
        self.style.configure("TButton", background="#808080", foreground="white")
        self.style.configure("high.TButton", background="#8FBC8B", foreground="white")
        self.style.configure("TLabel", background="#808080", foreground="white")
        self.style.map("TButton", background=[("pressed", "#404040"), ("active", "#A0A0A0")])

        frame = Frame(self, relief=FLAT, borderwidth=1)
        frame.pack(fill=BOTH, expand=1)

        subframe_0 = Frame(frame, relief=FLAT, borderwidth=0)
        subframe_0.pack(fill=X)
        lbl_0 = Label(subframe_0, text="App's machine-readable name (used for naming folders locally and remotely):", style="TLabel")
        lbl_0.pack(fill=BOTH, padx=10, pady=10)
        entry_0 = Entry(subframe_0)
        entry_0.pack(fill=X, padx=10, ipady=5)
        self.set_entry_text(entry_0, "")

        subframe_1 = Frame(frame, relief=FLAT, borderwidth=0)
        subframe_1.pack(fill=X)
        lbl_1 = Label(
            subframe_1, text="Where to create the app's folder locally:", style="TLabel")
        lbl_1.pack(fill=BOTH, padx=10, pady=10)
        entry_1 = Entry(subframe_1)

        def action_1():
            cdir = filedialog.askdirectory(title="Please select a directory")
            if cdir:
                self.set_entry_text(entry_1, cdir)

        button_1 = Button(subframe_1, text="Choose", command=action_1, style="TButton")
        button_1.pack(side=RIGHT, padx=10, pady=0)
        entry_1.pack(fill=X, padx=10, ipady=5)
        self.set_entry_text(entry_1, "")

        subframe_2 = Frame(frame, relief=FLAT, borderwidth=0)
        subframe_2.pack(fill=X)
        lbl_2 = Label(subframe_2, text="Remote host:", style="TLabel")
        lbl_2.pack(fill=BOTH, padx=10, pady=10)
        entry_2 = Entry(subframe_2)
        entry_2.pack(fill=X, padx=10, ipady=5)
        self.set_entry_text(entry_2, "")

        subframe_3 = Frame(frame, relief=FLAT, borderwidth=0)
        subframe_3.pack(fill=X)
        lbl_3 = Label(
            subframe_3, text="Remote SSH port (empty will mean the default port):", style="TLabel")
        lbl_3.pack(fill=BOTH, padx=10, pady=10)
        entry_3 = Entry(subframe_3)
        entry_3.pack(fill=X, padx=10, ipady=5)
        self.set_entry_text(entry_3, "")

        subframe_4 = Frame(frame, relief=FLAT, borderwidth=0)
        subframe_4.pack(fill=X)
        lbl_4 = Label(subframe_4, text="Remote user:", style="TLabel")
        lbl_4.pack(fill=BOTH, padx=10, pady=10)
        entry_4 = Entry(subframe_4)
        entry_4.pack(fill=X, padx=10, ipady=5)
        self.set_entry_text(entry_4, "")

        subframe_5 = Frame(frame, relief=FLAT, borderwidth=0)
        subframe_5.pack(fill=X)
        lbl_5 = Label(
            subframe_5, text="Local path to the SSH private key:", style="TLabel")
        lbl_5.pack(fill=BOTH, padx=10, pady=10)
        entry_5 = Entry(subframe_5)

        def action_5():
            cdir = filedialog.askopenfilename(title="Please select a private key")
            if cdir:
                self.set_entry_text(entry_5, cdir)

        button_5 = Button(subframe_5, text="Choose", command=action_5, style="TButton")
        button_5.pack(side=RIGHT, padx=10, pady=0)
        entry_5.pack(fill=X, padx=10, ipady=5)
        self.set_entry_text(entry_5, "")

        subframe_6 = Frame(frame, relief=FLAT, borderwidth=0)
        subframe_6.pack(fill=X)
        lbl_6 = Label(
            subframe_6, text="Where to create the app's folder remotely (should not be owned by root):", style="TLabel")
        lbl_6.pack(fill=BOTH, padx=10, pady=10)
        entry_6 = Entry(subframe_6)
        entry_6.pack(fill=X, padx=10, ipady=5)
        self.set_entry_text(entry_6, "/var/www")

        subframe_7 = Frame(frame, relief=FLAT, borderwidth=0)
        subframe_7.pack(fill=X)
        lbl_7 = Label(subframe_7, text="Sudo password:", style="TLabel")
        lbl_7.pack(fill=BOTH, padx=10, pady=10)
#.........这里部分代码省略.........
开发者ID:nazariyg,项目名称:InstaDjango,代码行数:103,代码来源:InstaDjango.py

示例10: Query

# 需要导入模块: from tkinter.ttk import Entry [as 别名]
# 或者: from tkinter.ttk.Entry import pack [as 别名]
class Query(Toplevel):
    """Base class for getting verified answer from a user.

    For this base class, accept any non-blank string.
    """
    def __init__(self, parent, title, message, *, text0='', used_names={},
                 _htest=False, _utest=False):
        """Create popup, do not return until tk widget destroyed.

        Additional subclass init must be done before calling this
        unless  _utest=True is passed to suppress wait_window().

        title - string, title of popup dialog
        message - string, informational message to display
        text0 - initial value for entry
        used_names - names already in use
        _htest - bool, change box location when running htest
        _utest - bool, leave window hidden and not modal
        """
        Toplevel.__init__(self, parent)
        self.withdraw()  # Hide while configuring, especially geometry.
        self.configure(borderwidth=5)
        self.resizable(height=False, width=False)
        self.title(title)
        self.transient(parent)
        self.grab_set()
        self.bind('<Key-Return>', self.ok)
        self.bind('<Key-Escape>', self.cancel)
        self.protocol("WM_DELETE_WINDOW", self.cancel)
        self.parent = parent
        self.message = message
        self.text0 = text0
        self.used_names = used_names
        self.create_widgets()
        self.update_idletasks()  # Needed here for winfo_reqwidth below.
        self.geometry(  # Center dialog over parent (or below htest box).
                "+%d+%d" % (
                    parent.winfo_rootx() +
                    (parent.winfo_width()/2 - self.winfo_reqwidth()/2),
                    parent.winfo_rooty() +
                    ((parent.winfo_height()/2 - self.winfo_reqheight()/2)
                    if not _htest else 150)
                ) )
        if not _utest:
            self.deiconify()  # Unhide now that geometry set.
            self.wait_window()

    def create_widgets(self):  # Call from override, if any.
        # Bind to self widgets needed for entry_ok or unittest.
        self.frame = frame = Frame(self, borderwidth=2, relief='sunken', )
        entrylabel = Label(frame, anchor='w', justify='left',
                           text=self.message)
        self.entryvar = StringVar(self, self.text0)
        self.entry = Entry(frame, width=30, textvariable=self.entryvar)
        self.entry.focus_set()

        buttons = Frame(self)
        self.button_ok = Button(buttons, text='Ok',
                width=8, command=self.ok)
        self.button_cancel = Button(buttons, text='Cancel',
                width=8, command=self.cancel)

        frame.pack(side='top', expand=True, fill='both')
        entrylabel.pack(padx=5, pady=5)
        self.entry.pack(padx=5, pady=5)
        buttons.pack(side='bottom')
        self.button_ok.pack(side='left', padx=5)
        self.button_cancel.pack(side='right', padx=5)

    def entry_ok(self):  # Example: usually replace.
        "Return non-blank entry or None."
        entry = self.entry.get().strip()
        if not entry:
            showerror(title='Entry Error',
                    message='Blank line.', parent=self)
            return None
        return entry

    def ok(self, event=None):  # Do not replace.
        '''If entry is valid, bind it to 'result' and destroy tk widget.

        Otherwise leave dialog open for user to correct entry or cancel.
        '''
        entry = self.entry_ok()
        if entry is not None:
            self.result = entry
            self.destroy()
        else:
            # [Ok] moves focus.  (<Return> does not.)  Move it back.
            self.entry.focus_set()

    def cancel(self, event=None):  # Do not replace.
        "Set dialog result to None and destroy tk widget."
        self.result = None
        self.destroy()
开发者ID:SharSmall,项目名称:cpython,代码行数:97,代码来源:query.py

示例11: HelpSource

# 需要导入模块: from tkinter.ttk import Entry [as 别名]
# 或者: from tkinter.ttk.Entry import pack [as 别名]
class HelpSource(Query):
    "Get menu name and help source for Help menu."
    # Used in ConfigDialog.HelpListItemAdd/Edit, (941/9)

    def __init__(self, parent, title, *, menuitem='', filepath='',
                 used_names={}, _htest=False, _utest=False):
        """Get menu entry and url/local file for Additional Help.

        User enters a name for the Help resource and a web url or file
        name. The user can browse for the file.
        """
        self.filepath = filepath
        message = 'Name for item on Help menu:'
        super().__init__(parent, title, message, text0=menuitem,
                 used_names=used_names, _htest=_htest, _utest=_utest)

    def create_widgets(self):
        super().create_widgets()
        frame = self.frame
        pathlabel = Label(frame, anchor='w', justify='left',
                          text='Help File Path: Enter URL or browse for file')
        self.pathvar = StringVar(self, self.filepath)
        self.path = Entry(frame, textvariable=self.pathvar, width=40)
        browse = Button(frame, text='Browse', width=8,
                        command=self.browse_file)

        pathlabel.pack(anchor='w', padx=5, pady=3)
        self.path.pack(anchor='w', padx=5, pady=3)
        browse.pack(pady=3)

    def askfilename(self, filetypes, initdir, initfile):  # htest #
        # Extracted from browse_file so can mock for unittests.
        # Cannot unittest as cannot simulate button clicks.
        # Test by running htest, such as by running this file.
        return filedialog.Open(parent=self, filetypes=filetypes)\
               .show(initialdir=initdir, initialfile=initfile)

    def browse_file(self):
        filetypes = [
            ("HTML Files", "*.htm *.html", "TEXT"),
            ("PDF Files", "*.pdf", "TEXT"),
            ("Windows Help Files", "*.chm"),
            ("Text Files", "*.txt", "TEXT"),
            ("All Files", "*")]
        path = self.pathvar.get()
        if path:
            dir, base = os.path.split(path)
        else:
            base = None
            if platform[:3] == 'win':
                dir = os.path.join(os.path.dirname(executable), 'Doc')
                if not os.path.isdir(dir):
                    dir = os.getcwd()
            else:
                dir = os.getcwd()
        file = self.askfilename(filetypes, dir, base)
        if file:
            self.pathvar.set(file)

    item_ok = SectionName.entry_ok  # localize for test override

    def path_ok(self):
        "Simple validity check for menu file path"
        path = self.path.get().strip()
        if not path: #no path specified
            showerror(title='File Path Error',
                      message='No help file path specified.',
                      parent=self)
            return None
        elif not path.startswith(('www.', 'http')):
            if path[:5] == 'file:':
                path = path[5:]
            if not os.path.exists(path):
                showerror(title='File Path Error',
                          message='Help file path does not exist.',
                          parent=self)
                return None
            if platform == 'darwin':  # for Mac Safari
                path =  "file://" + path
        return path

    def entry_ok(self):
        "Return apparently valid (name, path) or None"
        name = self.item_ok()
        path = self.path_ok()
        return None if name is None or path is None else (name, path)
开发者ID:SharSmall,项目名称:cpython,代码行数:88,代码来源:query.py

示例12: CreateCustomer

# 需要导入模块: from tkinter.ttk import Entry [as 别名]
# 或者: from tkinter.ttk.Entry import pack [as 别名]
class CreateCustomer(Frame):
  """Create customer screen"""
  
  def __init__(self, master):
    Frame.__init__(self,master)
    
    self.master = master
    self.frame = Frame(self.master)
    self.initUI()
  
  def initUI(self):
    self.master.title("3D Printer - Add Customer")
    self.style = Style()

    default_padding = {'padx': 10, 'pady' : 10}

    #TODO change alignment    
    #Left frame for labels
    self.left_frame = Frame(self.master)
    
    self.name_label = Label(self.left_frame, text = "Name", style="BW.TLabel")
    self.name_label.pack(default_padding)

    self.surname_label = Label(self.left_frame, text = "Surname", style="BW.TLabel")
    self.surname_label.pack(default_padding)    

    self.email_label = Label(self.left_frame, text = "Email", style="BW.TLabel")
    self.email_label.pack(default_padding)

    self.cellphone_label = Label(self.left_frame, text = "Cellphone", style="BW.TLabel")
    self.cellphone_label.pack(default_padding)

    #Right frame for entries
    self.right_frame = Frame(self.master)
    
    self.name_entry = Entry(self.right_frame)
    self.name_entry.pack(default_padding)    

    self.surname_entry = Entry(self.right_frame)
    self.surname_entry.pack(default_padding)

    self.email_entry = Entry(self.right_frame)
    self.email_entry.pack(default_padding)

    self.cellphone_entry = Entry(self.right_frame)
    self.cellphone_entry.pack(default_padding)
    
    #Bottom frame for button
    self.button_frame = Frame(self.master)
    self.create_customer_button = Button(self.button_frame, text = "Create Customer", command = self.save_customer)
    self.create_customer_button.pack(default_padding)

    self.button_frame.pack(side = BOTTOM, fill = "x", expand = True)
    self.left_frame.pack(side = LEFT, expand = True, fill = "y")
    self.right_frame.pack(side = RIGHT, expand = True, fill = "y")

    self.frame.pack()

  def save_customer(self):
    print("saving customer")

    self.customer = Customer(self.name_entry.get(), self.surname_entry.get(),
                             self.email_entry.get(), self.cellphone_entry.get())
    if not self.customer.validate():
      messagebox.showerror(message = "All fields are mandatory, please fill in all the fields")
      return
    
    db = TinyDB('db/db.json')
    self.customer_id = db.insert(self.customer.__dict__)
    
    #TODO redirect to next page
    self.go_to_execute_script()
  
  def go_to_execute_script(self):
    """redirect to next page"""
    
    self.execute_script = Toplevel(self, self.master)
    self.app = ExecuteScript(self.execute_script)
开发者ID:khlumzeemee,项目名称:3dprinter,代码行数:80,代码来源:Application.py

示例13: Frame

# 需要导入模块: from tkinter.ttk import Entry [as 别名]
# 或者: from tkinter.ttk.Entry import pack [as 别名]
bottom_frame = Frame(main_frame)

label = Label(top_frame, text="This is my Label")
entry = Entry(top_frame, textvariable=mystring)
radio = Radiobutton(top_frame, text="Enable", variable=myint, value=1)

text1 = Text(mid_frame)
text2 = Text(mid_frame)

ok_button = Button(bottom_frame, text="Ok", command=okbutton)
cancel_button = Button(bottom_frame, text="Cancel", command=exit)

###### Pack our Widgets #######
main_frame.pack()
top_frame.pack()
mid_frame.pack()
bottom_frame.pack(anchor="e")

label.pack(side="left")
entry.pack(side="left")
radio.pack(side="left")

text1.pack(side="left")
text2.pack(side="left")

cancel_button.pack(side="right", padx=5, pady=5)
ok_button.pack(side="right")


root.mainloop()
开发者ID:Exodus111,项目名称:Projects,代码行数:32,代码来源:test.py

示例14: add_entry

# 需要导入模块: from tkinter.ttk import Entry [as 别名]
# 或者: from tkinter.ttk.Entry import pack [as 别名]
 def add_entry(self, text):
     entry = Entry(self)
     entry.insert(0, "".join(text))
     entry.pack(fill="both", expand=True)
     entry.config(state="disable")
     self.entries.append(entry)
开发者ID:Exodus111,项目名称:Projects,代码行数:8,代码来源:load.py

示例15: initUI

# 需要导入模块: from tkinter.ttk import Entry [as 别名]
# 或者: from tkinter.ttk.Entry import pack [as 别名]
    def initUI(self):

        self.parent.title("Digital Cookbook")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1, side=BOTTOM)

        # Establish menu bar #
        menubar = Menu(self.parent)
        self.parent.config(menu=menubar)
        # Add file menu #
        filemenu = Menu(menubar, tearoff=0)
        menubar.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="Import recipe from XML file", command=self.xmlImport)
        filemenu.add_command(label="Add blank recipe to database", command=self.recipeAdd)
        filemenu.add_command(label="Delete recipe from database", command=self.recipeDelete)
        filemenu.add_command(label="Load recipe", command=self.recipeLoad)
        filemenu.add_command(label="Save recipe to database", command=self.recipeSave, accelerator="Ctrl+S")
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.onExit, accelerator="Ctrl+W")
        # Add help menu #
        helpmenu = Menu(menubar, tearoff=0)
        menubar.add_cascade(label="Help", menu=helpmenu)
        helpmenu.add_command(label="About...", command=self.helpAbout)

        # Establish toolbar #
        frameToolbar = Frame(self.parent)  # , relief=RAISED, borderwidth=1)
        frameToolbar.pack(side=TOP, fill=X)
        # Add buttons to toolbar #
        buffer = 2
        buttonspaceing = 100
        buttonwidth = 12
        buttonheight = 30
        bImportXML = Button(frameToolbar, text="Import XML", command=self.xmlImport, width=buttonwidth)
        bImportXML.pack(side=LEFT, padx=buffer, pady=buffer)
        bAddRecipe = Button(frameToolbar, text="Add Recipe", command=self.recipeAdd, width=buttonwidth)
        bAddRecipe.pack(side=LEFT, padx=buffer, pady=buffer)
        bDeleteRecipe = Button(frameToolbar, text="Delete Recipe", command=self.recipeDelete, width=buttonwidth)
        bDeleteRecipe.pack(side=LEFT, padx=buffer, pady=buffer)
        bEditRecipe = Button(frameToolbar, text="Load Recipe", command=self.recipeLoad, width=buttonwidth)
        bEditRecipe.pack(side=LEFT, padx=buffer, pady=buffer)
        bSaveRecipe = Button(frameToolbar, text="Save Recipe", command=self.recipeSave, width=buttonwidth)
        bSaveRecipe.pack(side=LEFT, padx=buffer, pady=buffer)

        # Recipe list section
        frameRecipeList = Frame(self, borderwidth=1, width=200)
        frameRecipeList.pack_propagate(0)
        frameRecipeList.pack(side=LEFT, fill=Y)
        Label(frameRecipeList, text="Recipe List").pack()
        # Category option menu
        default = StringVar(frameRecipeList)
        default.set("----")
        recipeCatagories = OptionMenu(frameRecipeList, default, "----", "None", "Cat 1", "Cat 2", "Cat 3")
        recipeCatagories.pack(side=TOP, fill=X)
        # Filter Frame
        frameFilter = Frame(frameRecipeList, relief=RAISED, borderwidth=1, width=200)
        frameFilter.pack(side=TOP, fill=X)
        Label(frameFilter, text="Filter...").pack()
        # Filter text
        filterText = Entry(frameFilter)
        filterText.pack_propagate(0)
        filterText.pack(side=LEFT, fill=X)
        # Filter Button
        filterButton = Button(frameFilter, text="Go", command=self.placeholder)
        filterButton.pack_propagate(0)
        filterButton.pack(side=RIGHT)
        # Recipe Box Frame
        frameRecipeBox = Frame(frameRecipeList, relief=RAISED, borderwidth=1)
        frameRecipeBox.pack(side=TOP, fill=BOTH, expand=1)
        # ==== Recipe List box ====
        recipeListScroll = Scrollbar(frameRecipeBox, orient=VERTICAL)
        self.recipeList = Listbox(frameRecipeBox, selectmode=EXTENDED, yscrollcommand=recipeListScroll.set)
        self.recipeList.pack(side=LEFT, fill=BOTH, expand=1)
        recipeListScroll.config(command=self.recipeList.yview)
        recipeListScroll.pack(side=RIGHT, fill=Y)

        self.getReciepList()
        self.populateRecipeList(self.recipes)

        # Spacer
        frameSpacer1 = Frame(self, borderwidth=1, width=10)
        frameSpacer1.pack_propagate(0)
        frameSpacer1.pack(side=LEFT, fill=Y)

        # Recipe info section
        frameRecipeInfo = Frame(self, borderwidth=1, width=200)
        frameRecipeInfo.pack_propagate(0)
        frameRecipeInfo.pack(side=LEFT, fill=Y)
        # Recipe name
        Label(frameRecipeInfo, text="Recipe Name:", anchor=E, justify=LEFT).pack()
        self.recipeName = Entry(frameRecipeInfo)
        self.recipeName.pack(side=TOP, fill=X)
        # Prep Time
        framePrepTime = Frame(frameRecipeInfo)
        framePrepTime.pack(side=TOP, fill=X)
        Label(framePrepTime, text="Prep Time:", anchor=E, justify=LEFT).pack()
        self.prepTime = Entry(framePrepTime)
        self.prepTime.pack(side=LEFT, fill=X)
        default = StringVar(framePrepTime)
        default.set("----")
#.........这里部分代码省略.........
开发者ID:RagingRoosevelt,项目名称:RecipeManagerV2,代码行数:103,代码来源:gui.py


注:本文中的tkinter.ttk.Entry.pack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。