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


Python Button.config方法代码示例

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


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

示例1: UndoButton

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import config [as 别名]
class UndoButton(Observer):
    '''Represent the 'undo' button in the Senku GUI.'''
    
    def __init__(self, game, parent):
        '''Constructor of UndoButton. Receive the game and the
        parent widget (frame, in this case).'''
        
        Observer.__init__(self)
        self._game = game
        self._game.add_observer(self, 'UNDO_STACK')
        self._button = Button(parent, text='Deshacer', command=self.undo)
        self._button.grid(row=1, column=1)
    
    
    def update(self, aspect, value):
        '''The aspect is always UNDO_STACK. If there's no undo
        actions, the button will be disabled.'''
        
        if value.is_empty():
            self._button.config(state=DISABLED)
        else:
            self._button.config(state=NORMAL)
    
    
    def undo(self):
        '''Tell the model to perform the undo action, if it's possible.'''

        self._game.undo()
开发者ID:ngarbezza,项目名称:pysenku,代码行数:30,代码来源:uisenku.py

示例2: ConfigWindow

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import config [as 别名]
class ConfigWindow(Toplevel):
    '''Represent the configuration window.'''
    
    def __init__(self, parent=None):
        '''Constructor of ConfigWindow.'''
        Toplevel.__init__(self, parent)
        self.title('Configuracion')
        self._states = [IntVar(value=CONFIG['GAME_TRACKING']), 
                        IntVar(value=CONFIG['CONFIRM_EXIT'])]
        self._cbox_gtrack = Checkbutton(self, text='Seguimiento del juego')
        self._cbox_gtrack.config(variable=self._states[0])
        self._cbox_confexit = Checkbutton(self, text='Confirmacion al salir')
        self._cbox_confexit.config(variable=self._states[1])
        self._cbox_gtrack.grid(row=0, column=0, sticky=W)
        self._cbox_confexit.grid(row=1, column=0, sticky=W)
        self._button_cancel = Button(self, text='Cancelar', command=self.destroy)
        self._button_cancel.grid(row=3, column=1, sticky=E)
        self._button_accept = Button(self, text='Guardar y Salir')
        self._button_accept.config(command=self.save_config)
        self._button_accept.grid(row=3, column=0, sticky=E)
        
    def save_config(self):
        pass
        
    def get_state_game_tracking(self):
        return self._states[0].get()
    
    def get_state_confirm_exit(self):
        return self._states[1].get()
开发者ID:ngarbezza,项目名称:pysenku,代码行数:31,代码来源:pysenku-0.5.py

示例3: GuiBasicSettings

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import config [as 别名]
class GuiBasicSettings(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.pack()
        
        #Unit
        self.sizeUnits = {"Byte": 1, "KiB":1024, "MiB":1024**2, "GiB":1024**3}
        
        self._initFile()
        self._initSize()

    def _initFile(self):
        self._fileLbl = Label(self, text="File:       ")
        self._fileTxt = Entry(self)
        self._fileTxt.insert(0, "/tmp/out.txt")
        self._fileBtn = Button(self, text="Create", command=self._callbackFun)
        self._fileLbl.grid(row=0, column=0)
        self._fileTxt.grid(row=0, column=1)
        self._fileBtn.grid(row=0, column=2)
    
    def _initSize(self):
        self._sizeLbl = Label(self, text="FileSize:  ")
        self._sizeTxt = Entry(self)
        self._sizeTxt.insert(0, "1024")
        
        self._sizeVar    = StringVar()
        self._sizeVar.set("Byte")       #FIXME: replace "Byte" with variable
        sizeOptParam = (self, self._sizeVar) + tuple(self.sizeUnits.keys()) 
        self._sizeOptMen = OptionMenu(*sizeOptParam)
        
        self._sizeLbl.grid(row=1, column=0)
        self._sizeTxt.grid(row=1, column=1)
        self._sizeOptMen.grid(row=1, column=2)
    
    def _callbackFun(self):
        print("_callbackBtn")
        self.outerCallback()
    
    def enableButton(self, enabled=True):
        if enabled:
            self._fileBtn.config(state="normal")
        else:
            self._fileBtn.config(state="disabled")
    def getFileName(self):
        return self._fileTxt.get()
        
    def getFileSize(self):
        mult = int(self.sizeUnits[self._sizeVar.get()])
        val  = int(self._sizeTxt.get())
        return val * mult   
    
    def setCallback(self, aCallback):
        self.outerCallback = aCallback
开发者ID:awaken1988,项目名称:pyTools,代码行数:56,代码来源:tas_bytegenerator.py

示例4: list_entries

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import config [as 别名]
    def list_entries(self, Medikom, results, entry_type):
        if entry_type == 0:   # tasks (left column)
            x = self.SPACE_TWO
        else:   # information (right column)
            x = self.WIN_WIDTH / 2 + (.25 * self.SPACE_ONE)
        for i, (id, ts, title) in enumerate(results):
            ts = self.format_ts(ts)
            task_button = Button(
                self, text=ts + title, font='Courier 10', anchor='w',
                command=Callable(self.view_details, Medikom, id))
            task_button.place(
                x=x, y=(i + 1) * (self.ROW_HIGHT + self.ROW_SPACE),
                width=(self.WIN_WIDTH / 2) - (1.25 * self.SPACE_ONE),
                height=self.ROW_HIGHT)
            rm_task_button = Button(
                self, text='√',
                command=Callable(self.rm_entry, Medikom, id, title))
            rm_task_button.place(
                x=x + (self.WIN_WIDTH / 2) - (1.25 * self.SPACE_ONE),
                y=(i + 1) * (self.ROW_HIGHT + self.ROW_SPACE),
                width=self.SPACE_TWO, height=self.ROW_HIGHT)

            # highlight selected entries and those with priority
            if self.selected_id and (id == self.selected_id):
                task_button.config(bg='lightblue')
                rm_task_button.config(bg='lightblue')
            if title.startswith('!'):
                task_button.config(bg='IndianRed2')
                rm_task_button.config(bg='IndianRed2')
开发者ID:g-murzik,项目名称:medikom,代码行数:31,代码来源:medikom_front_end.py

示例5: showup

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import config [as 别名]
class Dashboard:
    
    #顯示儀表板
    def showup(self):
        self.psr = Processor()
        self.root = Tk()
        self.root.title("MOPS資訊觀測站")
        frame = Frame(self.root)
        frame.grid(row=0, column=0, sticky="news")
        self.stateV = StringVar()
        self.stateV.set("日期格式:yyyymmdd")
        self.statebarL = Label(frame, textvariable=self.stateV)
        sdateL = Label(frame, text="開始日期")
        edateL = Label(frame, text="迄止日期")
        self.sdateE = Entry(frame)
        self.edateE = Entry(frame)
        self.goBtn = Button(frame, text="確定", command=self.runProcess)
        self.statebarL.grid(row=0, column=0, rowspan=1, columnspan=3, sticky="news")
        sdateL.grid(row=1, column=0, rowspan=1, columnspan=1, sticky="news")
        edateL.grid(row=2, column=0, rowspan=1, columnspan=1, sticky="news")
        self.sdateE.grid(row=1, column=1, rowspan=1, columnspan=1, sticky="news")
        self.edateE.grid(row=2, column=1, rowspan=1, columnspan=1, sticky="news")
        self.goBtn.grid(row=1, column=2, rowspan=2, columnspan=1, sticky="news")
        Grid.grid_rowconfigure(self.root, 0, weight=1)
        Grid.grid_columnconfigure(self.root, 0, weight=1)
        self.root.mainloop()
        
    #確定開始執行抓取資料
    def runProcess(self):
        self.goBtn.config(state="disabled")
        try:
            sdate = self.sdateE.get()
            edate = self.edateE.get()
            datetime.strptime(sdate, "%Y%m%d")
            datetime.strptime(edate, "%Y%m%d")
        except ValueError:
            self.stateV.set("日期格式錯誤,正確為:yyyymmdd")
            return None
        print("from " + sdate + " to " + edate)
        self.psr.setDateRange(sdate, edate)
        self.psr.registerProgressObserver(self) #observer 需實作 updateProgress
        t = Timer(0, self.psr.runProcess) #啟動另一個 thread 執行,畫面才不會「沒有回應」
        t.start()
        
    #進度更新
    def updateProgress(self, progress):
        self.stateV.set("進度:" + str(progress) + "%")
        if progress == 100:
            self.goBtn.config(state="normal")
            self.stateV.set("已完成。重新輸入日期:yyyymmdd")
开发者ID:muchu1983,项目名称:104_mops,代码行数:52,代码来源:dashboard.py

示例6: main

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import config [as 别名]
def main():
    root = Tk()

    a = Alarm(root)
    a.pack(side="bottom")

    textbox = Entry(root)
    textbox.pack(side="left")

    start = Button(root, text="Start",command= lambda: a.startTimer(int(textbox.get()), start, stop, textbox))
    start.pack(side="left")
    stop = Button(root, text="Stop",command= lambda: a.stop(start,stop))
    stop.config(state="disabled")
    stop.pack(side="left")
    reset = Button(root, text="Reset", command= lambda: a.reset(start,stop,textbox))
    reset.pack(side="left")

    root.mainloop()
开发者ID:KDvu,项目名称:python-alarm,代码行数:20,代码来源:main.py

示例7: __init__

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import config [as 别名]
 def __init__(self, game):
     '''Constructor of UISenku. Build the main window and the
     main frame.'''
     
     Observer.__init__(self)
     self._game = game
     self._root = Tk()
     self._root.title('PySenku')
     main_frame = Frame(self._root, width=280, height=330, bd=1)
     BoardArea(self._game, main_frame)
     start_button = Button(main_frame)
     start_button.config(text='Nuevo', command=self.start)
     start_button.grid(row=1, column=0)
     help_button = Button(main_frame)
     help_button.config(text='Mas info...', command=self.open_help)
     help_button.grid(row=1, column=2)
     UndoButton(self._game, main_frame)
     main_frame.pack()
     self._game.add_observer(self, 'GAME_OVER')
     self._root.protocol("WM_DELETE_WINDOW", self.quit)
开发者ID:ngarbezza,项目名称:pysenku,代码行数:22,代码来源:pysenku-0.2.py

示例8: initButtons

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import config [as 别名]
    def initButtons(self, ios, commands):
        for command in ios:
            cmdInstance = command()
            cmdButton = Button(self.topToolbar, image=self.res.get(command.get_id()), relief=GROOVE)
            cmdHandler = partial(self.onIOCommandClick, cmdButton, cmdInstance)
            cmdButton.config(command=cmdHandler)
            cmdButton.pack(side=LEFT, padx=2, pady=2)
            self.ioButtons.append(cmdButton)
            print("Added draw command: {} ({})".format(cmdInstance.get_name(), cmdInstance.get_description()))

        self.commandButtons = []
        for command in commands:
            cmdButton = Button(self.topToolbar, image=self.res.get(command.get_id()), relief=FLAT)
            cmdHandler = partial(self.onDrawCommandButtonClick, cmdButton, command)
            cmdButton.config(command=cmdHandler)
            cmdButton.pack(side=LEFT, padx=2, pady=2)
            self.commandButtons.append(cmdButton)
            print("Added IO command: {} ({})".format(command.get_name(), command.get_description()))

        cmdColorPicker = Button(self.topToolbar, relief=RIDGE)
        cmdHandler = partial(self.onChangeColor, cmdColorPicker)
        cmdColorPicker.config(command=cmdHandler, background=self.colorPicker.getColor(), relief=GROOVE, width=2,
                              highlightbackground='white')
        cmdColorPicker.pack(side=LEFT, padx=15, pady=2)
        self.colorPickerButton = cmdColorPicker
开发者ID:tu-tran,项目名称:DrawingProjectPython,代码行数:27,代码来源:gui.py

示例9: Amel

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import config [as 别名]
class Amel(LabelFrame):
    def __init__(self, boss, nom, amelioration, maximum, prix, up, logo):
        """
        amelioration (str) : Nom de l'amélioration du bouton
        maximum (int) : Maximum de fois que l'on peut augmenter l'amélioration
        prix (int) : Prix de l'amélioration par niveau
        up (int) : Montant de point apporté par l'amélioration
        """
        global imagesMag
        self.amel = amelioration
        self.max = maximum
        self.prix = prix
        self.up = up
        LabelFrame.__init__(self,  boss)
        Label(self, image=imagesMag[logo]).pack(side=LEFT)
        Label(self, text=nom, width=18).pack(side=LEFT)
        self.button = Button(self, command=self.acheter, width = 6)
        self.level = Label(self, width=5)
        self.total = Label(self, width=11)
        self.total.pack(side=RIGHT)
        self.level.pack(side=RIGHT)
        self.button.pack(side=RIGHT)
        self.maj()
    def maj(self):
        global amel, stat
        self.button.config(text=(str((amel[self.amel]+1)*self.prix) + ' PO'))
        self.level.config(text=str(amel[self.amel]) + '/' + str(self.max))
        self.total.config(text='Total : ' + str(stat[self.amel]))
    def acheter(self):
        global stat, OR, amel
        if ((OR >= (amel[self.amel]+1)*self.prix) and (amel[self.amel] < self.max)):
            OR -= (amel[self.amel]+1)*self.prix   #A changer
            stat[self.amel] += self.up
            amel[self.amel] += 1
            self.maj()
            __main__.menu.majPerso()
            __main__.menu.majOR()
开发者ID:Hugal31,项目名称:Donjon-Python,代码行数:39,代码来源:Magasin.py

示例10: LucteriosMainForm

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import config [as 别名]
class LucteriosMainForm(Tk):

    def __init__(self):
        Tk.__init__(self)
        try:
            img = Image("photo", file=join(
                dirname(import_module('lucterios.install').__file__), "lucterios.png"))
            self.tk.call('wm', 'iconphoto', self._w, img)
        except:
            pass
        self.has_checked = False
        self.title(ugettext("Lucterios installer"))
        self.minsize(475, 260)
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)
        self.running_instance = {}
        self.resizable(True, True)
        self.protocol("WM_DELETE_WINDOW", self.on_closing)

        self.ntbk = ttk.Notebook(self)
        self.ntbk.grid(row=0, column=0, columnspan=1, sticky=(N, S, E, W))

        self.create_instance_panel()
        self.create_module_panel()

        stl = ttk.Style()
        stl.theme_use("default")
        stl.configure("TProgressbar", thickness=5)
        self.progress = ttk.Progressbar(
            self, style="TProgressbar", orient='horizontal', mode='indeterminate')
        self.progress.grid(row=1, column=0, sticky=(E, W))

        self.btnframe = Frame(self, bd=1)
        self.btnframe.grid(row=2, column=0, columnspan=1)
        Button(self.btnframe, text=ugettext("Refresh"), width=20, command=self.refresh).grid(
            row=0, column=0, padx=3, pady=3, sticky=(N, S))
        self.btnupgrade = Button(
            self.btnframe, text=ugettext("Search upgrade"), width=20, command=self.upgrade)
        self.btnupgrade.config(state=DISABLED)
        self.btnupgrade.grid(row=0, column=1, padx=3, pady=3, sticky=(N, S))
        Button(self.btnframe, text=ugettext("Close"), width=20, command=self.on_closing).grid(
            row=0, column=2, padx=3, pady=3, sticky=(N, S))

    def on_closing(self):
        all_stop = True
        instance_names = list(self.running_instance.keys())
        for old_item in instance_names:
            if (self.running_instance[old_item] is not None) and self.running_instance[old_item].is_running():
                all_stop = False
        if all_stop or askokcancel(None, ugettext("An instance is always running.\nDo you want to close?")):
            self.destroy()
        else:
            self.refresh()

    def destroy(self):
        instance_names = list(self.running_instance.keys())
        for old_item in instance_names:
            if self.running_instance[old_item] is not None:
                self.running_instance[old_item].stop()
                del self.running_instance[old_item]
        Tk.destroy(self)

    def create_instance_panel(self):
        frm_inst = Frame(self.ntbk)
        frm_inst.grid_columnconfigure(0, weight=1)
        frm_inst.grid_rowconfigure(0, weight=1)
        frm_inst.grid_columnconfigure(1, weight=3)
        frm_inst.grid_rowconfigure(1, weight=0)
        self.instance_list = Listbox(frm_inst, width=20)
        self.instance_list.bind('<<ListboxSelect>>', self.select_instance)
        self.instance_list.pack()
        self.instance_list.grid(row=0, column=0, sticky=(N, S, W, E))

        self.instance_txt = Text(frm_inst, width=75)
        self.instance_txt.grid(row=0, column=1, rowspan=2, sticky=(N, S, W, E))
        self.instance_txt.config(state=DISABLED)

        self.btninstframe = Frame(frm_inst, bd=1)
        self.btninstframe.grid(row=1, column=0, columnspan=1)
        self.btninstframe.grid_columnconfigure(0, weight=1)
        Button(self.btninstframe, text=ugettext("Launch"), width=25, command=self.open_inst).grid(
            row=0, column=0, columnspan=2, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Modify"), width=10,
               command=self.modify_inst).grid(row=1, column=0, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Delete"), width=10,
               command=self.delete_inst).grid(row=1, column=1, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Save"), width=10,
               command=self.save_inst).grid(row=2, column=0, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Restore"), width=10,
               command=self.restore_inst).grid(row=2, column=1, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Add"), width=25, command=self.add_inst).grid(
            row=3, column=0, columnspan=2, sticky=(N, S))

        self.ntbk.add(frm_inst, text=ugettext('Instances'))

    def create_module_panel(self):
        frm_mod = Frame(self.ntbk)
        frm_mod.grid_columnconfigure(0, weight=1)
        frm_mod.grid_rowconfigure(0, weight=1)
        self.module_txt = Text(frm_mod)
#.........这里部分代码省略.........
开发者ID:povtux,项目名称:core,代码行数:103,代码来源:lucterios_gui.py

示例11: _Tk_Nosy

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import config [as 别名]
class _Tk_Nosy(object):
    """This class is the tkinter GUI object"""
    def __init__(self, master):
        self.dirname = os.path.abspath( os.curdir )

        self.initComplete = 0
        self.master = master
        self.x, self.y, self.w, self.h = -1,-1,-1,-1

        # bind master to <Configure> in order to handle any resizing, etc.
        # postpone self.master.bind("<Configure>", self.Master_Configure)
        self.master.bind('<Enter>', self.bindConfigure)

        self.menuBar = Menu(master, relief = "raised", bd=2)


        top_Directory = Menu(self.menuBar, tearoff=0)
        top_Directory.add("command", label = "Change Dir", command = self.menu_Directory_Change_Dir)
        self.menuBar.add("cascade", label="Directory", menu=top_Directory)


        #top_Snippet = Menu(self.menuBar, tearoff=0)

        self.menuBar.add("command", label = "Run", command = self.menu_Run)

        master.config(menu=self.menuBar)

        # make a Status Bar
        self.statusMessage = StringVar()
        self.statusMessage.set(self.dirname)
        self.statusbar = Label(self.master, textvariable=self.statusMessage, bd=1, relief=SUNKEN)
        self.statusbar.pack(anchor=SW, fill=X, side=BOTTOM)

        self.statusbar_bg = self.statusbar.cget('bg') # save bg for restore

        myFont = tkinter.font.Font(family="Arial", size=12, weight=tkinter.font.BOLD)
        self.statusbar.config( font=myFont )


        frame = Frame(master)
        frame.pack(anchor=NE, fill=BOTH, side=TOP)

        self.Pass_Fail_Button = Button(frame,text="Pass/Fail Will Be Shown Here",
                                       image="", width="15", background="green",
                                       anchor=W, justify=LEFT, padx=2)
        self.Pass_Fail_Button.pack(anchor=NE, fill=X, side=TOP)
        self.Pass_Fail_Button.bind("<ButtonRelease-1>", self.Pass_Fail_Button_Click)

        #self.master.title("tk_nosy")
        self.master.title('Python %s.%s.%s '%sys.version_info[:3])
        self.oscillator = 1 # animates character on title
        self.oscillator_B = 0 # used to return statusbar to statusbar_bg

        self.lbframe = Frame( frame )
        self.lbframe.pack(anchor=SE, side=LEFT, fill=BOTH, expand=1)

        scrollbar = Scrollbar(self.lbframe, orient=VERTICAL)
        self.Text_1 = Text(self.lbframe, width="80", height="24", yscrollcommand=scrollbar.set)
        scrollbar.config(command=self.Text_1.yview)
        scrollbar.pack(side=RIGHT, fill=Y)
        self.Text_1.pack(side=LEFT, fill=BOTH, expand=1)

        self.master.resizable(1,1) # Linux may not respect this

        self.numNosyCalls = 0
        self.need_to_pick_dir = 1

        if len(sys.argv)>1:
            #  I don't care what the exception is, if there's a problem, bail
            # pylint: disable=W0702
            try:
                dirname = os.path.abspath( sys.argv[1] )
                self.try_change_to_new_dir( dirname )
            except:
                pass # let Alarm force dir selection
        else:
            try:
                if os.path.isdir(os.path.join( self.dirname, 'tests' )):
                    self.try_change_to_new_dir( self.dirname )
            except:
                pass # let Alarm force dir selection
                

        print(LICENSE)
        self.Alarm()


    def try_change_to_new_dir(self, dirname):
        """A legal abspath will switch to dirname."""
        #  I don't care what the exception is, if there's a problem, bail
        # pylint: disable=W0702
        if dirname:
            try:
                dirname = os.path.abspath( dirname )
            except:
                return # let Alarm force dir selection
        else:
            return

        self.dirname = dirname
#.........这里部分代码省略.........
开发者ID:sonofeft,项目名称:PyProTem,代码行数:103,代码来源:tk_nosy.py

示例12: BioInfo

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import config [as 别名]
class BioInfo(Tk):
    def __init__(self):
        Tk.__init__(self)
        self.wm_title("BioInfo : comparaison des listes")
        self.resizable(width=FALSE, height=FALSE)
        self.SortDir = False

        # Lists Types
        self.typeList1 = None
        self.typeList2 = None

        # Frame content
        self.frameContent = Frame(self)
        self.frameContent.pack(side=TOP, fill=X)

        # ScrollBar
        scrollbar = Scrollbar(self.frameContent, orient=VERTICAL)
        scrollbar.pack(side=RIGHT, fill=Y)

        # Result Content
        self.dataCols = ('microArn_A', 'microArn_B', 'FoldC', 'p-Value', 'Note')
        self.tree = Treeview(self.frameContent, columns=self.dataCols, show = 'headings', yscrollcommand=scrollbar.set)

        # configure column headings
        for c in self.dataCols:
            self.tree.heading(c, text=c, command=lambda c=c: self.columnSort(c, self.SortDir))
            self.tree.column(c, width=10)

        self.tree.pack(side=LEFT, fill=X, expand="yes")

        scrollbar.config(command=self.tree.yview)

        # Frame Lists
        self.frameLists = Frame(self)
        self.frameLists.pack(side=LEFT)

        # Frame Forms
        self.frameForms = Frame(self)
        self.frameForms.pack(side=LEFT, padx=20)

        #Liste n°1 selection
        self.frameList1 = Frame(self.frameLists)
        self.frameList1.pack()

        self.typeListStr1 = StringVar(self.frameList1)
        self.typeListStr1.set(str(ListBioType.TypeA))

        self.buttonTypeList1 = OptionMenu(self.frameList1, self.typeListStr1, str(ListBioType.TypeA), str(ListBioType.TypeB)).pack(side=LEFT)

        self.entrylist1 = Entry(self.frameList1, width=30)
        self.entrylist1.pack(side=LEFT)

        self.buttonBrowseList1 = Button(self.frameList1, text="Parcourir", command=self.load_fileList1, width=10)
        self.buttonBrowseList1.pack(side=LEFT, padx=5)

        # List n°2 selection
        self.frameList2 = Frame(self.frameLists)
        self.frameList2.pack(side=BOTTOM)

        self.typeListStr2 = StringVar(self.frameList2)
        self.typeListStr2.set(str(ListBioType.TypeB))

        self.buttonTypeList2 = OptionMenu(self.frameList2, self.typeListStr2, str(ListBioType.TypeA), str(ListBioType.TypeB)).pack(side=LEFT)

        self.entrylist2 = Entry(self.frameList2, width=30)
        self.entrylist2.pack(side=LEFT)

        self.buttonBrowseList2 = Button(self.frameList2, text="Parcourir", command=self.load_fileList2, width=10)
        self.buttonBrowseList2.pack(side=LEFT, padx=5)

        # Form pValue
        self.framePVal = Frame(self.frameForms)
        self.framePVal.pack()

        Label(self.framePVal, text="pValue").pack(side=LEFT)
        self.entryPVal = Entry(self.framePVal, width=6)
        self.entryPVal.pack(side=LEFT)

        # Form foldC
        self.frameFoldC = Frame(self.frameForms)
        self.frameFoldC.pack()

        Label(self.frameFoldC, text="foldCh").pack(side=LEFT)
        self.entryFoldC = Entry(self.frameFoldC, width=6)
        self.entryFoldC.pack(side=LEFT)

        # Form note
        self.frameNote = Frame(self.frameForms)
        self.frameNote.pack()

        Label(self.frameNote, text="note    ").pack(side=LEFT)
        self.entryNote = Entry(self.frameNote, width=6)
        self.entryNote.pack(side=LEFT)

        # Bouton comparer
        self.buttonComparer = Button(self, text="Comparer", command=self.compare, width=10, state=DISABLED)
        self.buttonComparer.pack(fill= X, expand="yes", padx=20, pady=(10,0))

        #Bouton exporter
        self.buttonExport = Button(self, text="Exporter", command=self.export, width=10, state=DISABLED)
#.........这里部分代码省略.........
开发者ID:S0obi,项目名称:BioInfo,代码行数:103,代码来源:BioInfo.py

示例13: GUI

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import config [as 别名]
class GUI(Frame):
    def __init__(self, game, size, margin, colors=('black', 'white'), master=None):
        color = '#333333'
        Frame.__init__(self, master, bg=color)
        self.game = game
        self.cell_size = (size - 2*margin) / self.game.size
        self.coordinates = lambda position: self.cell_size * (np.array(position) + 1/2) + margin
        self.player_move = lambda event: self.move(pause=1000, event=event)
        self.grid()
        self.master.title("Pythello")
        self.colors = colors[::-1]  # Flip color order so that the first color input corresponds to player 1

        max_turns = self.game.size**2 - 4
        figure = Figure(figsize=(size/100, size/100), dpi=100, facecolor=color)
        axes = figure.add_subplot(111, axisbg=color)
        self.line = axes.plot(0, 0, 'w-', [0, max_turns], [0, 0], 'w--')[0]
        axes.grid(True, color='w')
        axes.set_xlim(0, max_turns)
        axes.set_ylim(-max_turns, max_turns)
        [tick.set_color('w') for axis in [axes.xaxis, axes.yaxis] for tick in axis.get_ticklines()]
        [label.set_color('w') for axis in [axes.xaxis, axes.yaxis] for label in axis.get_ticklabels()]
        [axes.spines[side].set_color('w') for side in ['top', 'bottom', 'left', 'right']]

        self.canvas = Canvas(self, width=size, height=size, background=color, highlightthickness=0)
        self.canvas.create_rectangle(margin, margin, size - margin, size - margin, outline='white')
        self.canvas.grid(row=0, column=1, rowspan=50)
        self.figure = FigureCanvasTkAgg(figure, master=self)
        self.figure.get_tk_widget().grid(row=0, column=2, rowspan=50)
        self.refresh()

        if all([isinstance(player, AI) for player in self.game.players]):
            self.play_button = Button(self, text='Play', highlightbackground=color, command=self.play)
            self.move_button = Button(self, text='Move', highlightbackground=color, command=self.move)
            self.reset_button = Button(self, text='Reset', highlightbackground=color, command=self.reset)
            self.play_button.grid(row=0, column=0)
            self.move_button.grid(row=1, column=0)
            self.reset_button.grid(row=2, column=0)
            self.running = False
        else:
            Button(self, text='Reset', highlightbackground=color, command=self.reset).grid(row=0, column=0)
            self.running = True

        for i in range(self.game.size):
            line_shift = self.cell_size * (i+1) + margin
            self.canvas.create_text(margin-10, line_shift - self.cell_size/2, text=str(i+1), fill='white')
            self.canvas.create_text(line_shift - self.cell_size/2, margin-10, text=chr(97+i), fill='white')
            self.canvas.create_line(margin, line_shift, size - margin, line_shift, fill='white')
            self.canvas.create_line(line_shift, margin, line_shift, size - margin, fill='white')

    def configure_buttons(self):
        (state, text, command) = ('disabled', 'Pause', self.pause) if self.running else ('normal', 'Reset', self.reset)
        self.play_button.config(state=state)
        self.move_button.config(state=state)
        self.reset_button.config(text=text, command=command)

    def draw_piece(self, position, radius, color):
        (y, x) = self.coordinates(position)
        return self.canvas.create_oval(x-radius, y-radius, x+radius, y+radius, fill=color, tags='circle')

    def move(self, pause=10, event=None):
        if event is None:
            move = self.game.player.move(self.game)
        else:
            move = eval(self.canvas.gettags(event.widget.find_withtag("current"))[-2])

        self.game.move(move)
        is_over = self.game.is_over()
        self.refresh()

        if not is_over and isinstance(self.game.player, AI) and self.running:
            self.after(pause, self.move)
        elif is_over:
            self.reset_button.config(text='Reset', command=self.reset)

    def pause(self):
        self.running = False
        self.configure_buttons()

    def play(self):
        self.running = True
        self.configure_buttons()
        self.move()

    def refresh(self):
        self.line.set_data(range(len(self.game.score)), self.game.score)
        self.figure.draw()
        [self.canvas.delete(tag) for tag in ['circle', 'text']]

        for position in zip(*np.nonzero(self.game.board)):
            color = self.colors[int((self.game.board[position] + 1) / 2)]
            self.draw_piece(position, (self.cell_size-2) / 2, color)

        if not isinstance(self.game.player, AI):
            for position in self.game.valid:
                (y, x) = self.coordinates(position)
                turned = len(self.game.valid[position]) - 1
                valid = self.draw_piece(position, self.cell_size / 4, 'green')
                self.canvas.addtag(str(position), 'withtag', valid)
                text = self.canvas.create_text(x+1, y+1, text=str(turned), tags=('text', str(position)))
                [self.canvas.tag_bind(tag, "<Button-1>", self.player_move) for tag in [valid, text]]
#.........这里部分代码省略.........
开发者ID:klane,项目名称:pythello,代码行数:103,代码来源:gui.py

示例14: __init__

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import config [as 别名]
class LintGui:
    """Build and control a window to interact with pylint"""

    def __init__(self, root=None):
        """init"""
        self.root = root or Tk()
        self.root.title("Pylint")
        # reporter
        self.reporter = None
        # message queue for output from reporter
        self.msg_queue = queue.Queue()
        self.msgs = []
        self.filenames = []
        self.rating = StringVar()
        self.tabs = {}
        self.report_stream = BasicStream(self)
        # gui objects
        self.lbMessages = None
        self.showhistory = None
        self.results = None
        self.btnRun = None
        self.information_box = None
        self.convention_box = None
        self.refactor_box = None
        self.warning_box = None
        self.error_box = None
        self.fatal_box = None
        self.txtModule = None
        self.status = None
        self.msg_type_dict = None
        self.init_gui()

    def init_gui(self):
        """init helper"""
        # setting up frames
        top_frame = Frame(self.root)
        mid_frame = Frame(self.root)
        radio_frame = Frame(self.root)
        res_frame = Frame(self.root)
        msg_frame = Frame(self.root)
        check_frame = Frame(self.root)
        history_frame = Frame(self.root)
        btn_frame = Frame(self.root)
        rating_frame = Frame(self.root)
        top_frame.pack(side=TOP, fill=X)
        mid_frame.pack(side=TOP, fill=X)
        history_frame.pack(side=TOP, fill=BOTH, expand=True)
        radio_frame.pack(side=TOP, fill=BOTH, expand=True)
        rating_frame.pack(side=TOP, fill=BOTH, expand=True)
        res_frame.pack(side=TOP, fill=BOTH, expand=True)
        check_frame.pack(side=TOP, fill=BOTH, expand=True)
        msg_frame.pack(side=TOP, fill=BOTH, expand=True)
        btn_frame.pack(side=TOP, fill=X)

        # Message ListBox
        rightscrollbar = Scrollbar(msg_frame)
        rightscrollbar.pack(side=RIGHT, fill=Y)
        bottomscrollbar = Scrollbar(msg_frame, orient=HORIZONTAL)
        bottomscrollbar.pack(side=BOTTOM, fill=X)
        self.lbMessages = Listbox(
            msg_frame, yscrollcommand=rightscrollbar.set, xscrollcommand=bottomscrollbar.set, bg="white"
        )
        self.lbMessages.pack(expand=True, fill=BOTH)
        rightscrollbar.config(command=self.lbMessages.yview)
        bottomscrollbar.config(command=self.lbMessages.xview)

        # History ListBoxes
        rightscrollbar2 = Scrollbar(history_frame)
        rightscrollbar2.pack(side=RIGHT, fill=Y)
        bottomscrollbar2 = Scrollbar(history_frame, orient=HORIZONTAL)
        bottomscrollbar2.pack(side=BOTTOM, fill=X)
        self.showhistory = Listbox(
            history_frame, yscrollcommand=rightscrollbar2.set, xscrollcommand=bottomscrollbar2.set, bg="white"
        )
        self.showhistory.pack(expand=True, fill=BOTH)
        rightscrollbar2.config(command=self.showhistory.yview)
        bottomscrollbar2.config(command=self.showhistory.xview)
        self.showhistory.bind("<Double-Button-1>", self.select_recent_file)
        self.set_history_window()

        # status bar
        self.status = Label(self.root, text="", bd=1, relief=SUNKEN, anchor=W)
        self.status.pack(side=BOTTOM, fill=X)

        # labels
        self.lblRatingLabel = Label(rating_frame, text="Rating:")
        self.lblRatingLabel.pack(side=LEFT)
        self.lblRating = Label(rating_frame, textvariable=self.rating)
        self.lblRating.pack(side=LEFT)
        Label(mid_frame, text="Recently Used:").pack(side=LEFT)
        Label(top_frame, text="Module or package").pack(side=LEFT)

        # file textbox
        self.txtModule = Entry(top_frame, background="white")
        self.txtModule.bind("<Return>", self.run_lint)
        self.txtModule.pack(side=LEFT, expand=True, fill=X)

        # results box
        rightscrollbar = Scrollbar(res_frame)
        rightscrollbar.pack(side=RIGHT, fill=Y)
#.........这里部分代码省略.........
开发者ID:OFFIS-Automation,项目名称:Framework,代码行数:103,代码来源:gui.py

示例15: Main

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import config [as 别名]
class Main():
    def __init__(self, parent, CPU_object):

        # Set up the basic variables and the frame
        self.cpu        = CPU_object
        self.parent     = parent
        self.parent.title("Main")
        self.frame      = Frame(parent)
        self.frame.config(pady = 10)
        self.running    = True
        self.reg_list   = RegisterListener(self.update_regs)

        # Set up the label at the top
        self.label      = Label(self.frame, text = "Registers: ")
        self.label.grid(row = 0, columnspan = 2)

        # Set up the labels and text-boxes for the registers
        self.register_text  = []
        self.register_label = []

        # A loop for setting the registers text boxes and labels
        for x in range(11):

            # Use tricky-tricks to not have to write in the values for the labels
            label_text = REV_VALUES[x] + ": "

            if x > 7:
                label_text = REV_VALUES[x + 19] + ": "

            self.register_label.append(Label(self.frame, text = label_text))
            self.register_text.append(Entry(self.frame, width = 25))

            self.register_label[x].grid(row = x + 1, column = 0)
            self.register_text[x].grid(row = x + 1, column = 1)

        #Set up the buttons into the frame
        self.monitor_button = Button(self.frame, text = "Open monitor", width = 25, command = self.open_monitor)
        self.watcher_button = Button(self.frame, text = "Open watcher", width = 25, command = self.open_watcher)
        self.run_button     = Button(self.frame, text = "Run program", width = 25, command = self.run_program)
        self.step_button    = Button(self.frame, text = "Step program", width = 25, command = self.step_program)
        self.stop_button    = Button(self.frame, text = "Stop program", width = 25, command = self.stop_program)

        # Pack the buttons
        self.monitor_button.grid(row = 12, columnspan = 2)
        self.watcher_button.grid(row = 13, columnspan = 2)
        self.run_button.grid(row = 14, columnspan = 2)
        self.step_button.grid(row = 15, columnspan = 2)
        self.stop_button.grid(row = 16, columnspan = 2)

        # Pack the frame
        self.frame.pack()

        # Handle the closing event (unregister the event listener)
        self.parent.protocol("WM_DELETE_WINDOW", self.handle_close)

    def step_program(self):

        # Step through the program and update the registers
        self.cpu.step()
        time.sleep(0.1)

        # Disable the buttons for step/run 
        if len(self.cpu.text) == self.cpu.PC:
            self.step_button.config(state = DISABLED)
            self.run_button.config(state = DISABLED)

    def run(self):

        while(len(self.cpu.text) != self.cpu.PC and self.running):
            self.step_program()

    def stop_program(self):
        self.running = False

    def run_program(self):
        self.running = True
        t = threading.Thread(target=self.run)
        t.start()
       # self.run()

    def update_text(self, obj, text):

        # Update the text in an Entry object
        obj.delete(0, END)
        obj.insert(0, text)

    def update_regs(self, data):
        
        # Update the general registers
        for i, reg in enumerate(self.cpu.regs):
            self.update_text(self.register_text[i], hex(reg))

        # Update SP, PC, and O
        self.update_text(self.register_text[8], hex(self.cpu.SP))
        self.update_text(self.register_text[9], hex(self.cpu.PC))
        self.update_text(self.register_text[10], hex(self.cpu.O))

    def handle_close(self):
        self.reg_list.unregister()
        self.parent.quit()
#.........这里部分代码省略.........
开发者ID:centip3de,项目名称:DCPU-16,代码行数:103,代码来源:gui.py


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