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


Python Entry.configure方法代码示例

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


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

示例1: PasswordDialog

# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import configure [as 别名]
class PasswordDialog(Dialog):

    def __init__(self, title, prompt, parent):
        self.prompt = prompt
        Dialog.__init__(self, parent, title)

    def body(self, master):
        from tkinter import Label
        from tkinter import Entry
        from tkinter import Checkbutton
        from tkinter import IntVar
        from tkinter import W

        self.checkVar = IntVar()

        Label(master, text=self.prompt).grid(row=0, sticky=W)

        self.e1 = Entry(master)

        self.e1.grid(row=0, column=1)

        self.cb = Checkbutton(master, text="Save to keychain", variable=self.checkVar)
        self.cb.pack()
        self.cb.grid(row=1, columnspan=2, sticky=W)
        self.e1.configure(show='*')

    def apply(self):
        self.result = (self.e1.get(), self.checkVar.get() == 1)
开发者ID:WaffleTime,项目名称:GUIDE,代码行数:30,代码来源:password_dialog.py

示例2: ProgramWidget

# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import configure [as 别名]
class ProgramWidget(Frame):

    def __init__(self, parent, client):
        super(ProgramWidget, self).__init__(parent)
        self.client = client
        self.client.onProgramChange = self.programChanged

        self.programLabel = Label(self, text = 'Program:')
        self.programLabel.grid(row = 0, column = 0)
        self.programEntry = Entry(self, text = 'Program name',
                                  state = 'readonly')
        self.programEntry.grid(row = 0, column = 1)
        self.buttonPanel = Frame(self)
        self.buttonPanel.grid(row = 1, column = 0, columnspan = 2, sticky = W)
        self.newButton = Button(self.buttonPanel, text='New',
                                command = self.newProgram)
        self.newButton.pack(side = LEFT)

    def programChanged(self):
        self.__setProgramText(str(self.client.state))

    def __setProgramText(self, text):
        self.programEntry.configure(state = NORMAL)
        self.programEntry.delete(0)
        self.programEntry.insert(0, text)
        self.programEntry.configure(state = 'readonly')

    def newProgram(self):
        self.client.makeNewProgram()
开发者ID:mindhog,项目名称:mawb,代码行数:31,代码来源:tkui.py

示例3: LabelEntry

# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import configure [as 别名]
class LabelEntry(Frame):
    def __init__(self, tk, name, text, **kwargs):
        super().__init__(tk, **kwargs)
        self.label = Label(self, text=name)
        self.entry = Entry(self, text=text)
        self.label.grid(row=0, column=0)
        self.entry.grid(row=0, column=1)

    def updateText(self, text):
        self.entry.configure(text=text)
开发者ID:wffirilat,项目名称:MyGame,代码行数:12,代码来源:LabelEntry.py

示例4: show

# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import configure [as 别名]
 def show(self):
     self.__menu = Frame(self.__window)
     self.__menu.configure(padx=10, pady=20)
     self.__menu.pack(fill=BOTH, expand=True)
     line1 = Frame(self.__menu)
     line1.pack(fill=X)
     self.__name = StringVar()
     self.__name.set("my_game_at_"+strftime("%H:%M")+"-"+strftime("%d.%m.%Y"))
     name_input = Entry(line1)
     name_input.configure(textvariable=self.__name)
     name_input.pack(fill=X)
     line2 = Frame(self.__menu)
     line2.pack(fill=X, pady=20)
     save_btn = Button(line2)
     save_btn.configure(text="Save Game", command=self.save)
     save_btn.pack(fill=X)
开发者ID:NasskalteJuni,项目名称:GameOfLife,代码行数:18,代码来源:SaveGui.py

示例5: Frame_SelectFilename

# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import configure [as 别名]
 class Frame_SelectFilename(LabelFrame):
     """Select a filename and path for the new Datastore file.
     
     Attributes
     ----------
     filename : str
         The full path and filename to the database file.
     
     """
     def __init__(self, **kwargs):
         super().__init__(**kwargs)
         self._isReady = False
         self.filename = None
         
         Grid.columnconfigure(self, 1, weight = 1)
         
         self.button = Button(self, text="Browse",
                              command=self.loadFile, width=10)
         self.button.grid(row = 0, column=1,
                          padx = 5, pady = 5, sticky = E)        
         
         self.entry = Entry(self, width = 65)
         self.entry.delete(0, END)
         self.entry.insert(0, 'Enter a path to a new datastore file...')
         self.entry.grid(row = 0, column = 0,
                         padx = 5, pady = 5, sticky = W)
         self.entry.configure(state = 'readonly')
         
     @property
     def isReady(self):
         return self._isReady
 
     def loadFile(self):
         fname = asksaveasfilename(filetypes=(('HDF5 files', '*.h5'),
                                              ('All files', '*.*')),
                                   title       = 'Select a new file...',
                                   initialfile = 'datastore.h5')
         if fname:
             self.filename = fname
             self.entry.configure(state = 'normal')
             self.entry.delete(0, END)
             self.entry.insert(0, fname)
             self.entry.configure(state = 'readonly')
             self._isReady = True
开发者ID:kmdouglass,项目名称:bstore,代码行数:46,代码来源:_createdatastore.py

示例6: Frame_SelectSearchPath

# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import configure [as 别名]
 class Frame_SelectSearchPath(LabelFrame):
     """Select a path to search for files to build the database with.
     
     Attributes
     ----------
     searchPath : str
     
     """
     def __init__(self, **kwargs):
         super().__init__(**kwargs)
         self._isReady   = False
         self.searchPath = None
         
         Grid.columnconfigure(self, 1, weight = 1)
         
         self.button = Button(self, text="Browse",
                              command=self.loadFile, width=10)
         self.button.grid(row=0, column=1,
                          padx = 5, pady = 5, sticky = E)        
         
         self.entry = Entry(self, width = 65)
         self.entry.delete(0, END)
         self.entry.insert(
             0, 'Enter the directory containing the input files...')
         self.entry.grid(row = 0, column = 0,
                         padx = 5, pady = 5, sticky = W)
         self.entry.configure(state = 'readonly')
         
     @property
     def isReady(self):
         return self._isReady
 
     def loadFile(self):
         fname = askdirectory(title = 'Select a search directory...',
                              mustexist = True)
         if fname:
             self.searchPath = fname
             self.entry.configure(state = 'normal')
             self.entry.delete(0, END)
             self.entry.insert(0, fname)
             self.entry.configure(state = 'readonly')
             self._isReady = True
开发者ID:kmdouglass,项目名称:bstore,代码行数:44,代码来源:_createdatastore.py

示例7: MLNQueryGUI

# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import configure [as 别名]
class MLNQueryGUI(object):
    def __init__(self, master, gconf, directory=None):
        self.master = master

        self.initialized = False

        self.master.bind('<Return>', self.infer)
        self.master.bind('<Escape>', lambda a: self.master.quit())
        self.master.protocol('WM_DELETE_WINDOW', self.quit)

        self.dir = os.path.abspath(ifnone(directory, ifnone(gconf['prev_query_path'], os.getcwd())))

        self.frame = Frame(master)
        self.frame.pack(fill=BOTH, expand=1)
        self.frame.columnconfigure(1, weight=1)

        row = 0
        # pracmln project options
        Label(self.frame, text='PRACMLN Project: ').grid(row=row, column=0,
                                                         sticky='ES')
        project_container = Frame(self.frame)
        project_container.grid(row=row, column=1, sticky="NEWS")

        # new proj file
        self.btn_newproj = Button(project_container, text='New Project...', command=self.new_project)
        self.btn_newproj.grid(row=0, column=1, sticky="WS")

        # open proj file
        self.btn_openproj = Button(project_container, text='Open Project...', command=self.ask_load_project)
        self.btn_openproj.grid(row=0, column=2, sticky="WS")

        # save proj file
        self.btn_updateproj = Button(project_container, text='Save Project...', command=self.noask_save_project)
        self.btn_updateproj.grid(row=0, column=3, sticky="WS")

        # save proj file as...
        self.btn_saveproj = Button(project_container, text='Save Project as...', command=self.ask_save_project)
        self.btn_saveproj.grid(row=0, column=4, sticky="WS")

        # grammar selection
        row += 1
        Label(self.frame, text='Grammar: ').grid(row=row, column=0, sticky='E')
        grammars = ['StandardGrammar', 'PRACGrammar']
        self.selected_grammar = StringVar()
        self.selected_grammar.trace('w', self.settings_setdirty)
        l = OptionMenu(*(self.frame, self.selected_grammar) + tuple(grammars))
        l.grid(row=row, column=1, sticky='NWE')

        # logic selection
        row += 1
        Label(self.frame, text='Logic: ').grid(row=row, column=0, sticky='E')
        logics = ['FirstOrderLogic', 'FuzzyLogic']
        self.selected_logic = StringVar()
        self.selected_logic.trace('w', self.settings_setdirty)
        l = OptionMenu(*(self.frame, self.selected_logic) + tuple(logics))
        l.grid(row=row, column=1, sticky='NWE')

        # mln section
        row += 1
        Label(self.frame, text="MLN: ").grid(row=row, column=0, sticky='NE')
        self.mln_container = FileEditBar(self.frame, directory=self.dir,
                                         filesettings={'extension': '.mln', 'ftypes': [('MLN files', '.mln')]},
                                         defaultname='*unknown{}',
                                         importhook=self.import_mln,
                                         deletehook=self.delete_mln,
                                         projecthook=self.save_proj,
                                         filecontenthook=self.mlnfilecontent,
                                         fileslisthook=self.mlnfiles,
                                         updatehook=self.update_mln,
                                         onchangehook=self.project_setdirty)
        self.mln_container.editor.bind("<FocusIn>", self._got_focus)
        self.mln_container.grid(row=row, column=1, sticky="NEWS")
        self.mln_container.columnconfigure(1, weight=2)
        self.frame.rowconfigure(row, weight=1)

        row += 1
        self.use_emln = IntVar()
        self.use_emln.set(0)
        self.cb_use_emln = Checkbutton(self.frame, text="use model extension",
                                       variable=self.use_emln,
                                       command=self.onchange_use_emln)
        self.cb_use_emln.grid(row=row, column=1, sticky="W")

        # mln extension section
        row += 1
        self.emlncontainerrow = row
        self.emln_label = Label(self.frame, text="EMLN: ")
        self.emln_label.grid(row=self.emlncontainerrow, column=0, sticky='NE')
        self.emln_container = FileEditBar(self.frame,
                                          directory=self.dir,
                                          filesettings={'extension': '.emln', 'ftypes': [('MLN extension files','.emln')]},
                                          defaultname='*unknown{}',
                                          importhook=self.import_emln,
                                          deletehook=self.delete_emln,
                                          projecthook=self.save_proj,
                                          filecontenthook=self.emlnfilecontent,
                                          fileslisthook=self.emlnfiles,
                                          updatehook=self.update_emln,
                                          onchangehook=self.project_setdirty)
        self.emln_container.grid(row=self.emlncontainerrow, column=1, sticky="NEWS")
#.........这里部分代码省略.........
开发者ID:bbferka,项目名称:pracmln,代码行数:103,代码来源:mlnquery.py

示例8: Main

# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import configure [as 别名]
class Main(Frame):
    def __init__(self, parent, controller):
        Frame.__init__(self, parent)
        self.controller = controller
        self.db_set = False

        self.configure(relief=GROOVE)
        self.configure(borderwidth="2")

        # Manual link adding
        self.manual_btn = Button(self)
        self.manual_btn.place(relx=0.07, rely=0.81, height=45, width=130)
        self.manual_btn.configure(activebackground="#d9d9d9")
        self.manual_btn.configure(highlightbackground="#d9d9d9")
        self.manual_btn.configure(pady="0")
        self.manual_btn.configure(text="Add manually")
        self.manual_btn.configure(width=130)

        self.file_btn = Button(self)
        self.file_btn.place(relx=0.67, rely=0.81, height=45, width=150)
        self.file_btn.configure(activebackground="#d9d9d9")
        self.file_btn.configure(highlightbackground="#d9d9d9")
        self.file_btn.configure(pady="0")
        self.file_btn.configure(text="Add from file")

        self.label = Label(self)
        self.label.place(relx=0.08, rely=0.0, height=61, width=484)
        self.label.configure(text="Create new playlists and add content to them")
        self.label.configure(width=485)

        self.listbox = Listbox(self)
        self.listbox.place(relx=0.38, rely=0.22, relheight=0.31, relwidth=0.17)
        self.listbox.configure(background="white")
        self.listbox.configure(disabledforeground="#a3a3a3")
        self.listbox.configure(foreground="#000000")
        self.listbox.configure(selectmode=SINGLE)
        self.listbox.configure(width=105)
        for name, value in config.configparser.items('Playlists'):
            if os.path.isdir(value):
                self.listbox.insert('end', name)
            else:
                config.remove_value('Playlists', name)
        self.listbox.bind('<<ListboxSelect>>', self.onselect)

        self.label_name = Label(self)
        self.label_name.place(relx=0.7, rely=0.22, height=31, width=84)
        self.label_name.configure(foreground="#000000")
        self.label_name.configure(text="Name")
        self.label_name.configure(width=85)

        self.entry = Entry(self)
        self.entry.place(relx=0.63, rely=0.31, relheight=0.08, relwidth=0.29)
        self.entry.configure(background="white")
        self.entry.configure(foreground="#000000")
        self.entry.configure(insertbackground="black")
        self.entry.configure(takefocus="0")
        self.entry.configure(width=175)

        self.change_name = Button(self)
        self.change_name.place(relx=0.7, rely=0.42, height=34, width=97)
        self.change_name.configure(activebackground="#d9d9d9")
        self.change_name.configure(highlightbackground="#d9d9d9")
        self.change_name.configure(highlightcolor="black")
        self.change_name.configure(pady="0")
        self.change_name.configure(text="Rename")
        self.change_name.configure(width=100)

        self.new_playlist = Button(self, command=self.new_database)
        self.new_playlist.place(relx=0.08, rely=0.28, height=54, width=107)
        self.new_playlist.configure(activebackground="#d9d9d9")
        self.new_playlist.configure(highlightbackground="#d9d9d9")
        self.new_playlist.configure(highlightcolor="black")
        self.new_playlist.configure(pady="0")
        self.new_playlist.configure(text="Create new playlist")
        self.new_playlist.configure(width=105)

        self.db_name = Entry(self)
        self.db_name.place(relx=0.07, rely=0.44, relheight=0.08, relwidth=0.22)
        self.db_name.configure(fg='grey')
        self.db_name.configure(width=135)
        self.db_name.insert(0, "Input database name here")
        self.db_name.bind('<Button-1>', lambda event: greytext(self.db_name))

    def onselect(self, event):
        w = event.widget
        index = int(w.curselection()[0])
        value = w.get(index)
        set_database(config.configparser.get('Playlists', value))
        if not database.check_integrity():
            messagebox.showwarning('Integrity check failed', 'You might be missing some entries in your list')
        if not self.db_set:
            self.manual_btn.configure(command=lambda: self.controller.show_frame('AddManually'))
            self.file_btn.configure(command=lambda: self.controller.show_frame('ReadFromFile'))
            self.db_set = True

    def new_database(self):
        name = self.db_name.get()
        names = config.configparser.options('Playlists')
        print(name, names)
        if name.strip() == '' or self.db_name.cget('fg') == 'grey':
#.........这里部分代码省略.........
开发者ID:s0hvaperuna,项目名称:Custom-playlist,代码行数:103,代码来源:addlink.py

示例9: Example

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

        self.parent = parent
        self.initUI()

    def initUI(self):
        self.parent.title("")
        # self.style = Style()
        # self.style.theme_use("clam")
        # self.pack(fill=BOTH, expand = 1)

        self.quitbutton = Button(self, text="Quit", command=lambda: self.quit())

        self.quitbutton.grid(row=3, column=1, pady=4)

        self.labelErrorPointer = Label(self, text="◀")

        self.labellist = []
        self.entrylist = []
        self.verifylist = []
        self.misclist = []

        self.optionCreate = "Create"
        self.optionUpcoming = "Upcoming"
        self.optionPast = "Past"

        self.prevmode = self.optionCreate
        self.curmode = self.optionCreate
        self.optionvar = tkinter.StringVar(self)
        self.optionvar.trace("w", self.permaloop)
        self.optionvar.set(self.optionCreate)
        self.option = OptionMenu(self, self.optionvar, self.optionCreate, self.optionUpcoming, self.optionPast)

        self.optionpostmodevar = tkinter.StringVar(self)
        self.optionpostmodevar.trace("w", self.permaloop)
        self.optionpostmodevar.set("url")
        self.optionpostmode = OptionMenu(self, self.optionpostmodevar, "url", "text")

        self.labelText = Label(self, text="Selftext:")
        self.entryText = Text(self)
        self.labelURL = Label(self, text="URL:")
        self.entryURL = Entry(self)
        self.entryURL.configure(width=60)

        self.sql = sqlite3.connect("sql.db")
        print("Loaded SQL Database")
        self.cur = self.sql.cursor()

        self.cur.execute(
            "CREATE TABLE IF NOT EXISTS upcoming(ID TEXT, SUBREDDIT TEXT, TIME INT, TITLE TEXT, URL TEXT, BODY TEXT)"
        )
        self.cur.execute(
            "CREATE TABLE IF NOT EXISTS past(ID TEXT, SUBREDDIT TEXT, TIME INT, TITLE TEXT, URL TEXT, BODY TEXT, POSTLINK TEXT)"
        )
        self.cur.execute("CREATE TABLE IF NOT EXISTS internal(NAME TEXT, ID INT)")
        print("Loaded Completed table")
        self.cur.execute("SELECT * FROM internal")
        f = self.cur.fetchone()
        if not f:
            print("Database is new. Adding ID counter")
            self.cur.execute("INSERT INTO internal VALUES(?, ?)", ["counter", 1])
            self.idcounter = 1
        else:
            self.idcounter = f[1]
            print("Current ID counter: " + str(self.idcounter))

        self.sql.commit()

        sw = self.parent.winfo_screenwidth()
        sh = self.parent.winfo_screenheight()

        w = 853
        h = 480
        x = (sw - w) / 2
        y = (sh - h) / 2

        self.parent.geometry("%dx%d+%d+%d" % (w, h, x, y - 50))

        self.login()

    def login(self):

        try:
            self.quitbutton.grid_forget()
            self.quitbutton.grid(row=9000, column=0, columnspan=20)

            self.option.grid(row=1, column=0, columnspan=8, pady=8)

            self.updategui(fullclean=True)
        except praw.errors.InvalidUserPass:
            pass
            print("Invalid username or password")
            self.entryPassword.delete(0, 200)
            self.labelErrorPointer.grid(row=1, column=2)

    def permaloop(self, *args):
        self.curmode = self.optionvar.get()
        print("Was: " + self.prevmode + " | Now: " + self.curmode)
#.........这里部分代码省略.........
开发者ID:Vindora,项目名称:reddit,代码行数:103,代码来源:scheduleclient.py

示例10: Example

# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import configure [as 别名]
class Example(Frame):

    def __init__(self, parent):
        Frame.__init__(self, parent)

        self.parent = parent
        self.initUI()

    def initUI(self):
        self.parent.title("")
        #self.style = Style()
        #self.style.theme_use("clam")
        #self.pack(fill=BOTH, expand = 1)


        self.quitbutton = Button(self, text="Quit", command= lambda: self.quit())

        self.quitbutton.grid(row=3, column=1, pady=4)

        self.labelErrorPointer = Label(self, text="◀")

        self.labellist = []
        self.entrylist = []
        self.verifylist = []
        self.misclist = []
                
        self.optionCreate = "Create"
        self.optionUpcoming = "Upcoming"
        self.optionPast = "Past"

        self.prevmode = self.optionCreate
        self.curmode = self.optionCreate
        self.optionvar = tkinter.StringVar(self)
        self.optionvar.trace("w",self.permaloop)
        self.optionvar.set(self.optionCreate)
        self.option = OptionMenu(self, self.optionvar, self.optionCreate, self.optionUpcoming, self.optionPast)

        self.optionpostmodevar = tkinter.StringVar(self)
        self.optionpostmodevar.trace("w",self.permaloop)
        self.optionpostmodevar.set('url')
        self.optionpostmode = OptionMenu(self, self.optionpostmodevar, 'url', 'text')

        self.labelText = Label(self, text='Selftext:')
        self.entryText = Text(self)
        self.labelURL = Label(self, text='URL:')
        self.entryURL = Entry(self)
        self.entryURL.configure(width=60)  

        self.sql = sqlite3.connect('sql.db')
        print('Loaded SQL Database')
        self.cur = self.sql.cursor()

        self.cur.execute('CREATE TABLE IF NOT EXISTS upcoming(ID TEXT, SUBREDDIT TEXT, TIME INT, TITLE TEXT, URL TEXT, BODY TEXT)')
        self.cur.execute('CREATE TABLE IF NOT EXISTS past(ID TEXT, SUBREDDIT TEXT, TIME INT, TITLE TEXT, URL TEXT, BODY TEXT, POSTLINK TEXT)')
        self.cur.execute('CREATE TABLE IF NOT EXISTS internal(NAME TEXT, ID INT)')
        print('Loaded Completed table')
        self.cur.execute('SELECT * FROM internal')
        f = self.cur.fetchone()
        if not f:
            print('Database is new. Adding ID counter')
            self.cur.execute('INSERT INTO internal VALUES(?, ?)', ['counter', 1])
            self.idcounter = 1
        else:
            self.idcounter = f[1]
            print('Current ID counter: ' + str(self.idcounter))

        self.sql.commit()
        

        
        sw = self.parent.winfo_screenwidth()
        sh = self.parent.winfo_screenheight()


        w=853
        h=480
        x = (sw - w) / 2
        y = (sh - h) / 2

        self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y-50))

        self.login()
        

    def login(self):

        try:
            self.quitbutton.grid_forget()
            self.quitbutton.grid(row=9000, column=0, columnspan=20)          

            self.option.grid(row=1,column=0,columnspan=80,pady=8)

            self.updategui(fullclean=True)
        except praw.errors.InvalidUserPass:
            pass
            print('Invalid username or password')
            self.entryPassword.delete(0,200)
            self.labelErrorPointer.grid(row=1, column=2)

    def permaloop(self, *args):
#.........这里部分代码省略.........
开发者ID:A-J-,项目名称:reddit,代码行数:103,代码来源:scheduleclient.py

示例11: FilePickEdit

# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import configure [as 别名]
class FilePickEdit(Frame):
    
    def __init__(self, master, file_mask, default_file, edit_height = None, user_onChange = None, 
                 rename_on_edit=0, font = None, coloring=True, allowNone=False, highlighter=None, directory='.'):
        """
            file_mask: file mask (e.g. "*.foo") or list of file masks (e.g. ["*.foo", "*.abl"])
        """
        self.master = master
        self.directory = directory
        self.user_onChange = user_onChange
        Frame.__init__(self, master)
        row = 0
        self.unmodified = True
        self.allowNone = allowNone
        self.file_extension = ""
        if type(file_mask) != list:
            file_mask = [file_mask]
        if "." in file_mask[0]:
            self.file_extension = file_mask[0][file_mask[0].rfind('.'):]
        # read filenames
        self.file_mask = file_mask
        self.updateList()
        # filename frame
        self.list_frame = Frame(self)
        self.list_frame.grid(row=row, column=0, sticky="WE")
        self.list_frame.columnconfigure(0, weight=1)
        # create list
        self.picked_name = StringVar()
        self.makelist()
        # refresh button
        self.refresh_button = Button(self.list_frame, text='<- refresh', command=self.refresh, height=1)
        self.refresh_button.grid(row=0, column=1, sticky='E')        
        # save button
        self.save_button = Button(self.list_frame, text="save", command=self.save, height=1)
        self.save_button.grid(row=0, column=2, sticky="E")
        # editor
        row += 1
        if coloring:
            self.editor = SyntaxHighlightingText(self, self.onEdit, highlighter=highlighter)
        else:
            self.editor = ScrolledText2(self, self.onEdit)
        if font is not None:
            self.editor.configure(font=font)
        if edit_height is not None:
            self.editor.configure(height=edit_height)
        self.editor.grid(row=row, column=0, sticky="NEWS")
        self.rowconfigure(row, weight=1)
        self.columnconfigure(0, weight=1)
        # option to change filename on edit
        row += 1
        self.options_frame = Frame(self)
        self.options_frame.grid(row=row, column=0, sticky=W)
        self.rename_on_edit = IntVar()
        self.cb = Checkbutton(self.options_frame, text="rename on edit", variable=self.rename_on_edit)
        self.cb.pack(side=LEFT)
        self.cb.configure(command=self.onChangeRename)
        self.rename_on_edit.set(rename_on_edit)
        # filename frame
        row += 1
        self.filename_frame = Frame(self)
        self.filename_frame.grid(row=row, column=0, sticky="WE")
        self.filename_frame.columnconfigure(0, weight=1)
        # save as filename
        self.save_name = StringVar()
        self.save_edit = Entry(self.filename_frame, textvariable = self.save_name)
        self.save_edit.grid(row=0, column=0, sticky="WE")
        self.save_name.trace("w", self.onSaveChange)
        # pick default if applicableButton
        self.select(default_file)
        self.row = row
        
    def setDirectory(self, directory, keep=False):
        self.directory = directory
        self.updateList()
        self.makelist()
#         menu = self.list["menu"] scrolledlist
#         menu = self.list.listbox#["scrolledlist"]
#         menu.delete(0, 'end')
        # add the new ones
#         for filename in self.files:
#             menu.add_command(label=filename, command=_setit(self.picked_name, filename, None))
        # if keep is true, only the files list will be updated but the content of the
        # text area will not be altered/removed
        if not keep: self.select("")
    
    def refresh(self):
        sel = self.get()
        self.updateList()
        self.select(sel, notify=False)
    
    def reloadFile(self):
        self.editor.delete("1.0", END)
        filename = self.picked_name.get()
        if os.path.exists(os.path.join(self.directory, filename)):
            new_text = open(os.path.join(self.directory, filename)).read()
            if new_text.strip() == "":
                new_text = "// %s is empty\n" % filename
            new_text = new_text.replace("\r", "")
        else:
            new_text = ""
#.........这里部分代码省略.........
开发者ID:bbferka,项目名称:pracmln,代码行数:103,代码来源:widgets.py

示例12: __init__

# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import configure [as 别名]
class testGUI:
    def __init__(self, master):
        """initialize GUI"""
        self.root = master
        self.on = True
        self.connection = None
        Tk().withdraw()
        self.basicframe = Frame(self.root)
        self.basicframe.grid()
        self.basicframe.configure(bg=bgcolor)

        self.fr = Frame(self.basicframe)
        self.fr.grid(row=0, column=0, sticky='new')  # , sticky='W')
        self.fr.configure(bg=bgcolor)
        Grid.columnconfigure(self.root, 0, weight=1)

        self.port = None
        self.baud = None
        # self.inputTypes = ['ascii', 'bin', 'hex', 'mix']
        self.inputType = StringVar()
        self.inputType.set('ascii')
        self.input = 'ascii'

        self.labelPort = Label(self.fr, width=10, text='PORT', justify='left', anchor='w', bg=bgcolor, fg=fgcolor, font=("Calibri", 12))
        self.entryPort = Entry(self.fr, width=20, bd=3, justify='left', bg=inputbox, fg=fgcolor)

        self.labelBaud = Label(self.fr, text='BAUD', justify='left', anchor='w', bg=bgcolor, fg=fgcolor, font=("Calibri", 12))
        self.entryBaud = Entry(self.fr, width=20, bd=3, justify='right', bg=inputbox, fg=fgcolor)

        self.labelType = Label(self.fr, text='TYPE', justify='left', anchor='w', bg=bgcolor, fg=fgcolor, font=("Calibri", 12))
        self.radioType1 = Radiobutton(self.fr, text='ascii', variable=self.inputType, value='ascii', indicatoron=0)
        self.radioType2 = Radiobutton(self.fr, text='bin', variable=self.inputType, value='bin', width=20, indicatoron=0)
        self.radioType3 = Radiobutton(self.fr, text='hex', variable=self.inputType, value='hex', indicatoron=0)
        self.radioType4 = Radiobutton(self.fr, text='mix', variable=self.inputType, value='mix', width=20, indicatoron=0)

        self.labelInput = Label(self.fr, text='INPUT', justify='left', anchor='w', bg=bgcolor, fg=fgcolor, font=("Calibri", 12))
        self.entryInput = Entry(self.fr, width=20, bd=3, justify='left', bg=inputbox, fg=fgcolor)

        self.buttonSend = Button(self.fr, text='SEND', justify='center', bg=buttoncolor, command=self.send)
        self.buttonRead = Button(self.fr, text='READ', justify='center', bg=buttoncolor, command=self.read)
        self.buttonExit = Button(self.fr, text='EXIT', justify='center', bg='red', fg='white', command=self.exit)

        self.response = StringVar()
        self.response.set('')
        self.responseBar = Label(self.fr, textvariable=self.response, justify='left', anchor='w',
                                 bg=bgcolor, fg=fgcolor, font=("Calibri", 12))
        self.status = StringVar()
        self.statusBar = Label(self.fr, textvariable=self.status, justify='left', anchor='nw',
                               bg=bgcolor, fg=fgcolor, font=("Calibri", 10))
        self.status.set('Initialized')


    def emptyRow(self, nrow):
        Label(self.fr, text="", bg=bgcolor).grid(row=nrow, column=0)

    def configure_connection(self):
        self.status.set('Configuring connection')
        print ('Configuring connection')
        self.port = self.entryPort.get()
        self.baud = self.entryBaud.get()
        print ('{}:{}'.format(self.port, self.baud))
        try:
            self.baud = int(self.baud)
        except:
            print ('Something went wrong, setting baud to 0')
            self.entryBaud.delete(0, END)
            self.entryBaud.insert(0, '0')
            self.baud = 0

        self.connection = RS232(comport=self.port, baud=self.baud, dictionary={}, timeout=1)
        self.connection.connect()
        print ('Connection status: {}'.format(self.connection))

        if self.connection and self.connection.conn:
            print ('Connection established, locking current settings')
            self.entryPort.configure(state='disabled')
            self.entryBaud.configure(state='disabled')
        else:
            print ('No connection')
            self.status.set('<No connection>')

    def convertInput(self):
        self.status.set('Converting input')
        typ = self.inputType.get()
        self.input = self.entryInput.get()
        if typ == 'bin':
            newInput = ''.join(lambda x: x in '01', self.input)
            self.input = chr(int(newInput, 2))
        elif typ == 'hex':
            newInput = ''.join(lambda x: x in '0123456789ABCDEF', self.input)
            self.input = chr(int(newInput, 16))
        elif typ == 'mix':
            newInput = self.input
            for i in re.findall('<(\d+?)>', inp):
                newInput = newInput.replace('<{}>'.format(i), chr(int(i)))
            self.input = newInput
        print ('Converted input: {}'.format(self.input))

    def send(self):
        # self.input = self.entryInput.get()
#.........这里部分代码省略.........
开发者ID:mimmon,项目名称:comparator,代码行数:103,代码来源:test232.py

示例13: __init__

# 需要导入模块: from tkinter import Entry [as 别名]
# 或者: from tkinter.Entry import configure [as 别名]
class HW6:
    def __init__(self):
        self.win = Tk()
        self.guiSetup()
        self.win.mainloop()

    def guiSetup(self):    # Setups GUI
        self.counter = 0
        self.searched = []
        self.counter2 = 0

        self.f1 = Frame(self.win)  # Top frame
        self.f1.grid(row=0,column=1)

        l1 = Label(self.f1, text = 'Number Search File')
        l1.grid(row=0,column=0)                                 # Search Labels
        l2 = Label(self.f1,text = 'Number Bank File    ')
        l2.grid(row = 1, column = 0)

        self.e1 = Entry(self.f1,state = 'readonly')   # Num Search File Display
        self.e1.grid(row = 0, column =1,columnspan = 6 )

        self.e2 = Entry(self.f1,state = 'readonly')  # Num Bank File Display
        self.e2.grid(row=1,column=1,columnspan = 6)

        self.f2 = Frame(self.win)  # Bottom Frame, holds grid
        self.f2.grid(row = 2, column = 1)

        self.f3 = Frame(self.win, relief = 'raised', border = 4) # Holds num bank numbers
        self.f3.grid(row = 2, column = 2)

        b1 = Button(self.f1,text = 'Select File',command = self.openNSClicked) # Search file open
        b1.grid(row = 0, column = 8)

        b2 = Button(self.f1,text = 'Select File', command=self.openNBClicked)  # Bank file open
        b2.grid(row = 1, column = 8)

        b3 = Button(self.f1,text = 'Generate Number Search',command=self.generate) # generates grid
        b3.grid(row=2,column=0)

        self.functionRan = [False,False] # shows if both files have been selected

    def openNSClicked(self):  # Opens num search file
        self.fileName = filedialog.askopenfilename(title = 'Select a number search file')
        self.e1.configure(state = 'normal')
        self.e1.insert(0,self.fileName) # sets display to file path
        self.e1.configure(state = 'readonly')

        self.functionRan[0] = True # shows it has been ran

    def openNBClicked(self): # Opens num bank file
        self.fileName1 = filedialog.askopenfilename(title = 'Select a number bank file')

        self.e2.configure(state = 'normal')
        self.e2.insert(0,self.fileName1)  # Sets display to file path
        self.e2.configure(state = 'readonly')

        self.functionRan[1] = True # shows it has been ran

    def readFile(self): # Takes in search file and creates dict of labels of values
        f1 = open(self.fileName,'r')
        CSVReader = csv.reader(f1)
        rawRows = []
        for row in CSVReader:
            rawRows.append(row) # converts csv file rows to normal raw rows in nested list
        f1.close()

        length = len(rawRows)
        # self.rows = []
        # if self.fileName[-1:-4:-1] != 'vsc':
        #     messagebox.showwarning(title = 'Excuse me!', message = 'Invalid file! >:(')
        #     self.openNSClicked() # re open file dialog and re try
        #     if self.readFileBool == True:
        #         self.readFile()
        #         self.readFileBool = False
        #
        # if self.fileName1[-1:-4:-1] != 'vsc':
        #     messagebox.showwarning(title = 'Excuse me!', message = 'Invalid file! >:(')
        #     self.openNBClicked() # re open file dialog and re try
        #     if self.readFileBool == True and self.counter2 == 0:
        #         self.readFile()
        #         self.readFileBool = False
        #         self.counter2 += 1
        # if self.fileName1[-1:-4:-1] == 'vsc' and self.fileName[-1:-4:-1] == 'vsc':
        #     self.readFileBool == False

        self.rows = []
        for rawRow in rawRows:
            pos = rawRows.index(rawRow) # y value
            row = []
            self.rows.append(row) # creates empty lists at each y value in final rows list
            for item in rawRow:
                item = item.strip() # gets rid of white space

                try:
                    ['-','=','+','*','/','0','1','2','3','4','5','6','7','8','9'].index(item)
                    self.rows[pos].append(item) #appends y value in rows with item in x value

                except: # if there is an item not acceptable
                    messagebox.showwarning(title = 'Excuse me!', message = 'Invalid file! >:(')
#.........这里部分代码省略.........
开发者ID:snitsnit,项目名称:Misc-Portfolio,代码行数:103,代码来源:NumGame.py


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