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


Python Frame.config方法代码示例

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


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

示例1: create_region

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import config [as 别名]
    def create_region(self, tid):
        """
        create and fill frame-region inside frame
        """
        region_owner = self.board[tid]["owner"]
        if region_owner is None:
            owner_text = "Unoccupied"
            tile_color = None
            own_tile = False
        else:
            own_tile = True if region_owner == game.player.name else False
            owner_text = "Owner: " + str(region_owner)
            tile_color = COLOURS[self.player_names.index(region_owner)]

        my_frame = Frame(self.frame_map, height=3 * self.size - 1,
                         width=3 * self.size - 1, bd=1, relief="flat",
                         bg = tile_color)
            
        x = int(tid.split("_")[1])
        N = int(sqrt(len(self.board)))
        my_frame.grid(row=int((x - 1)/ N),column=(x - 1) % N)
        counter_text = "Troops: " + str(game.board[tid]["counters"])

        button_pic = Button(my_frame, image = self.gifs[game.board[tid]["terrain"]],
                    name = tid, command = lambda: self.conquer_region(tid))
        label_owner = Label(my_frame, text=owner_text, bg = tile_color)
        label_counters = Label(my_frame, text=counter_text, bg = tile_color)
        
        if own_tile:
            button_plus = Button(my_frame, image = self.gifs["plus"],
                                 command=lambda: self.reinforce(tid, 1))
            button_minus = Button(my_frame, image = self.gifs["minus"],
                                  command=lambda: self.reinforce(tid, -1))

            button_plus.grid(row = 0, column=0)
            button_pic.grid(row = 0, column=1)
            button_minus.grid(row=0, column=2)

            label_owner.grid(row=1, columnspan=3)
            label_counters.grid(row=2, columnspan=3)
        else:
            button_pic.grid(row=0, column=1)
            label_owner.grid(row=1, column=1)
            label_counters.grid(row=2, column=1)

        if tid in game.player.adjacent_regions:
            my_frame.config(relief = "raised")
开发者ID:mkerin,项目名称:SmallWorlds,代码行数:49,代码来源:sim_game_state_gui.py

示例2: Edit

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import config [as 别名]
class Edit(Frame):
    def __init__(self, master, valves):
        Frame.__init__(self, master, bg='sky blue', width=1366, height=768)
        self.master = master

        self.canvas = Canvas(self, height=630, width=1320, bg='sky blue')
        self.frame = Frame(self.canvas, bg='sky blue')
        self.scrollbar = Scrollbar(self, orient='vertical', command=self.canvas.yview)
        self.scrollbar.configure(activebackground='DarkRed', background='red', width=40)
        self.canvas.configure(yscrollcommand=self.scrollbar.set, scrollregion=[0, 0, 1366, 800])

        self.scrollbar.pack(side='right', fill='y')
        self.canvas.pack(side='left')
        self.canvas.create_window((0, 0), window=self.frame, anchor='nw')
        
        self.valves = valves
        self.frame.config(bg='sky blue')

        index = 0
        while index < 10:
            self.frame.grid_rowconfigure(index, minsize=80)
            self.frame.grid_columnconfigure(index, minsize=30)
            index += 1

        self.frame.grid_columnconfigure(3, minsize=130)
        self.frame.grid_columnconfigure(6, minsize=130)

        interval = Label(self.frame, text='RUN', width=6, font=('Lucida Console', 30))
        interval.grid(row=0, column=2)
        interval.config(bg='sky blue', fg='RoyalBlue4')

        delay = Label(self.frame, text='DELAY', width=6, font=('Lucida Console', 30))
        delay.grid(row=0, column=5)
        delay.config(bg='sky blue', fg='RoyalBlue4')

        self.seconds = [IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar()]

        for each in self.seconds:
            each.set(0)

        self.set_seconds()

        self.valve_label = [Label(self.frame, textvariable=self.valves[0].get_name()),
                            Label(self.frame, textvariable=self.valves[1].get_name()),
                            Label(self.frame, textvariable=self.valves[2].get_name()),
                            Label(self.frame, textvariable=self.valves[3].get_name()),
                            Label(self.frame, textvariable=self.valves[4].get_name()),
                            Label(self.frame, textvariable=self.valves[5].get_name()),
                            Label(self.frame, textvariable=self.valves[6].get_name()),
                            Label(self.frame, textvariable=self.valves[7].get_name())
                            ]
       
        row = 1
        for each in self.valve_label:
            each.grid(row=row, column=0)
            each.config(width=8, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4')
            row += 1

        self.minus_image = PhotoImage(file="img/minus.png").subsample(x=5, y=5)
        self.minusInterval = [Button(self.frame, image=self.minus_image, command=lambda: self.subtract(0)),
                              Button(self.frame, image=self.minus_image, command=lambda: self.subtract(1)),
                              Button(self.frame, image=self.minus_image, command=lambda: self.subtract(2)),
                              Button(self.frame, image=self.minus_image, command=lambda: self.subtract(3)),
                              Button(self.frame, image=self.minus_image, command=lambda: self.subtract(4)),
                              Button(self.frame, image=self.minus_image, command=lambda: self.subtract(5)),
                              Button(self.frame, image=self.minus_image, command=lambda: self.subtract(6)),
                              Button(self.frame, image=self.minus_image, command=lambda: self.subtract(7)),
                              ]

        row = 1
        for each in self.minusInterval:
            each.grid(row=row, column=1)
            each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white')
            row += 1

        self.labelInterval = [Label(self.frame, textvariable=self.seconds[0]),
                              Label(self.frame, textvariable=self.seconds[1]),
                              Label(self.frame, textvariable=self.seconds[2]),
                              Label(self.frame, textvariable=self.seconds[3]),
                              Label(self.frame, textvariable=self.seconds[4]),
                              Label(self.frame, textvariable=self.seconds[5]),
                              Label(self.frame, textvariable=self.seconds[6]),
                              Label(self.frame, textvariable=self.seconds[7])]
#.........这里部分代码省略.........
开发者ID:xistingsherman,项目名称:SPTOR,代码行数:103,代码来源:Edit.py

示例3: Main

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame 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

示例4: Preferences

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import config [as 别名]
class Preferences(Frame):
    def __init__(self, master, valves):
        Frame.__init__(self, master, bg='sky blue', width=1366, height=768)
        self.master = master

        self.canvas = Canvas(self, height=640, width=1300, bg='sky blue')
        self.frame = Frame(self.canvas, bg='sky blue')
        self.frame.bind('<Button-1>', self.process_click_out)

        self.scrollbar = Scrollbar(self, orient='vertical', command=self.canvas.yview)
        self.scrollbar.configure(activebackground='DarkRed', background='red', width=40)
        self.canvas.configure(yscrollcommand=self.scrollbar.set, scrollregion=[0, 0, 1366, 2100])

        self.scrollbar.pack(side='right', fill='y')
        self.canvas.pack(side='left')
        self.canvas.create_window((0, 0), window=self.frame, anchor='nw')

        self.keyboard = Keyboard(self.master)

        self.valves = valves
        self.frame.config(bg='sky blue')
        
        index = 0
        while index < 25:
            self.frame.grid_rowconfigure(index, minsize=80)
            self.frame.grid_columnconfigure(index, minsize=150)
            index += 1

        num_label = [Label(self.frame, text='1'),
                     Label(self.frame, text='2'),
                     Label(self.frame, text='3'),
                     Label(self.frame, text='4'),
                     Label(self.frame, text='5'),
                     Label(self.frame, text='6'),
                     Label(self.frame, text='7'),
                     Label(self.frame, text='8'),
                     ]
        row = 1
        for each in num_label:
            each.grid(row=row, column=0)
            each.config(width=3, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4')
            row += 3

        text_label = [Label(self.frame, text='VALVE 1:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: '),

                     Label(self.frame, text='VALVE 2:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: '),

                     Label(self.frame, text='VALVE 3:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: '),

                     Label(self.frame, text='VALVE 4:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: '),

                     Label(self.frame, text='VALVE 5:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: '),

                     Label(self.frame, text='VALVE 6:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: '),

                     Label(self.frame, text='VALVE 7:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: '),

                     Label(self.frame, text='VALVE 8:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: ')

                     ]
        row = 1
        for each in text_label:
            each.grid(row=row, column=1)
            each.config(width=12, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4')
            row += 1

        self.valve_label = [Label(self.frame, textvariable=self.valves[0].get_name()),
                            Label(self.frame, textvariable=self.valves[1].get_name()),
                            Label(self.frame, textvariable=self.valves[2].get_name()),
                            Label(self.frame, textvariable=self.valves[3].get_name()),
                            Label(self.frame, textvariable=self.valves[4].get_name()),
                            Label(self.frame, textvariable=self.valves[5].get_name()),
                            Label(self.frame, textvariable=self.valves[6].get_name()),
                            Label(self.frame, textvariable=self.valves[7].get_name())]
        row = 1 
        for each in self.valve_label:
            each.grid(row=row, column=2)
            each.config(width=12, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4', anchor='w')
            each.bind('<Button-1>', self.process_click_out)
            row += 3

        self.entry_field = [Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
#.........这里部分代码省略.........
开发者ID:xistingsherman,项目名称:SPTOR,代码行数:103,代码来源:Preferences.py

示例5: RunScreen

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import config [as 别名]
class RunScreen(Frame):
    def __init__(self, master, valves):
        Frame.__init__(self, master, bg='sky blue', width=950, height=750)
        self.master = master
        self.valves = valves
        self.threads = []
        
        self.canvas = Canvas(self, height=750, width=950, bg='sky blue')
        self.frame = Frame(self.canvas, bg='sky blue')
        self.scrollbar = Scrollbar(self, orient='vertical', command=self.canvas.yview)
        self.scrollbar.configure(activebackground='DarkRed', background='red', width=40)
        self.canvas.configure(yscrollcommand=self.scrollbar.set, scrollregion=[0, 0, 1366, 1300])

        self.scrollbar.pack(side='right', fill='y')
        self.canvas.pack(side='left')
        self.canvas.create_window((0, 0), window=self.frame, anchor='nw')

        self.frame.config(bg='sky blue')

        self.valve_num = [Label(self.frame, text='1'),
                            Label(self.frame, text='2'),
                            Label(self.frame, text='3'),
                            Label(self.frame, text='4'),
                            Label(self.frame, text='5'),
                            Label(self.frame, text='6'),
                            Label(self.frame, text='7'),
                            Label(self.frame, text='8')]

        row = 0
        for each in self.valve_num:
            each.grid(row=row, column=0)
            each.config(width=4, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4')
            row += 2

        self.valve_name = [Label(self.frame, textvariable=valves[0].get_name()),
                            Label(self.frame, textvariable=valves[1].get_name()),
                            Label(self.frame, textvariable=valves[2].get_name()),
                            Label(self.frame, textvariable=valves[3].get_name()),
                            Label(self.frame, textvariable=valves[4].get_name()),
                            Label(self.frame, textvariable=valves[5].get_name()),
                            Label(self.frame, textvariable=valves[6].get_name()),
                            Label(self.frame, textvariable=valves[7].get_name())]

        row = 0
        for each in self.valve_name:
            each.grid(row=row, column=2)
            each.config(width=15, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4')
            row += 2

        valve = 0
        self.valve_activity = []
        self.on_image = PhotoImage(file="img/yes.png").subsample(x=6, y=6)
        self.off_image = PhotoImage(file="img/no.png").subsample(x=6, y=6)
        for each in self.valves:
            if each.get_setting() is 'INACTIVE':
                self.valve_activity.append(Button(self.frame, image=self.off_image, text='OFF', command=lambda: self.activate(valve)))
            else:
                self.valve_activity.append(Button(self.frame, image=self.on_image, text='ON', command=lambda: self.activate(valve)))
            valve += 1

        row = 0
        for each in self.valve_activity:
            each.grid(row=row, column=1)
            each.config(bg='SkyBlue4', activebackground='midnight blue')
            each.config()
            row += 2

        self.valve_action_a = [Label(self.frame, textvariable=valves[0].get_action_a()),
                               Label(self.frame, textvariable=valves[1].get_action_a()),
                               Label(self.frame, textvariable=valves[2].get_action_a()),
                               Label(self.frame, textvariable=valves[3].get_action_a()),
                               Label(self.frame, textvariable=valves[4].get_action_a()),
                               Label(self.frame, textvariable=valves[5].get_action_a()),
                               Label(self.frame, textvariable=valves[6].get_action_a()),
                               Label(self.frame, textvariable=valves[7].get_action_a())]

        row = 0
        for each in self.valve_action_a:
            each.grid(row=row, column=3)
            each.config(width=10, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4', anchor='w')
            row += 2

        self.valve_action_b = [Label(self.frame, textvariable=valves[0].get_action_b()),
                               Label(self.frame, textvariable=valves[1].get_action_b()),
                               Label(self.frame, textvariable=valves[2].get_action_b()),
                               Label(self.frame, textvariable=valves[3].get_action_b()),
                               Label(self.frame, textvariable=valves[4].get_action_b()),
                               Label(self.frame, textvariable=valves[5].get_action_b()),
                               Label(self.frame, textvariable=valves[6].get_action_b()),
                               Label(self.frame, textvariable=valves[7].get_action_b())]

        row = 1
        for each in self.valve_action_b:
            each.grid(row=row, column=3)
            each.config(width=10, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4', anchor='w')
            row += 2

        self.lightsA = [LED(self.frame, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
#.........这里部分代码省略.........
开发者ID:xistingsherman,项目名称:SPTOR,代码行数:103,代码来源:RunScreen.py


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