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


Python Button.grid_remove方法代码示例

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


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

示例1: __init__

# 需要导入模块: from tkinter import Button [as 别名]
# 或者: from tkinter.Button import grid_remove [as 别名]

#.........这里部分代码省略.........
                  Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(1), value=0),
                  Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(2), value=0),
                  Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(3), value=0),
                  Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(4), value=0),
                  Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(5), value=0),
                  Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(6), value=0),
                  Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(7), value=0)]

        index = 0
        for each in self.b:
            each.grid(row=index % 4, column=3)
            each.config(width=4, height=2,  indicatoron=0, variable=self.v[index], font=('Lucida Console', 30))
            each.config(bg='SkyBlue4', activebackground='midnight blue', selectcolor='midnight blue', fg='white')
            each.config(activeforeground='white')
            index += 1

        self.end_image = PhotoImage(file="img/no.png").subsample(x=6, y=6)
        self.end_button = [Radiobutton(self.frame1, image=self.end_image, command=lambda: self.end(0)),
                           Radiobutton(self.frame1, image=self.end_image, command=lambda: self.end(1)),
                           Radiobutton(self.frame1, image=self.end_image, command=lambda: self.end(2)),
                           Radiobutton(self.frame1, image=self.end_image, command=lambda: self.end(3)),
                           Radiobutton(self.frame2, image=self.end_image, command=lambda: self.end(4)),
                           Radiobutton(self.frame2, image=self.end_image, command=lambda: self.end(5)),
                           Radiobutton(self.frame2, image=self.end_image, command=lambda: self.end(6)),
                           Radiobutton(self.frame2, image=self.end_image, command=lambda: self.end(7)),
                           ]

        index = 0
        for each in self.end_button:
            each.grid(row=index % 4, column=5)
            each.config(value=2, variable=self.v[index], indicatoron=0)
            each.config(bg='brown3', activebackground='brown4')
            index += 1
        

    def make_frame(self):
        self.frame1.grid(row=2, column=0, rowspan=5)
        self.frame2.grid(row=2, column=1, rowspan=5)
        self.end_all_button.grid(row=1, column=0, columnspan=2)

        row = 0
        for each in self.lightsA:
            each.grid(row=row % 4, column=1, padx=20, pady=20)
            row += 1

        row = 0
        for each in self.lightsB:
            each.grid(row=row % 4, column=4, padx=20, pady=20)
            row += 1


    def delete_frame(self):
        self.frame1.grid_remove()
        self.frame2.grid_remove()
        self.end_all_button.grid_remove()

        for each in self.lightsA:
            each.grid_remove()

        for each in self.lightsB:
            each.grid_remove()

    def activate_a(self, number):
        pin_number = 65 + number
        pin_opposite = 80 - number

        if self.v[number].get() == 1:
            self.lightsA[number].set_state(True)
            self.lightsB[number].set_state(False)
            
            wiringpi.digitalWrite(pin_number, 1)
            wiringpi.digitalWrite(pin_opposite, 0)

    def activate_b(self, number):
        pin_number = 80 - number
        pin_opposite = 65 + number

        if self.v[number].get() == 0:
            self.lightsA[number].set_state(False)
            self.lightsB[number].set_state(True)
            wiringpi.digitalWrite(pin_number, 1)
            wiringpi.digitalWrite(pin_opposite, 0)
            

    def end(self, number):
        pin_number = 65 + number
        pin_opposite = 80 - number

        wiringpi.digitalWrite(pin_number, 0)
        wiringpi.digitalWrite(pin_opposite, 0)

        self.v[number].set(3)
        self.lightsA[number].set_state(False)
        self.lightsB[number].set_state(False)

    def end_all(self):
        number = 0
        while number < 8:
            self.end(number)
            number += 1
开发者ID:xistingsherman,项目名称:SPTOR,代码行数:104,代码来源:MomentaryPi2.py


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