日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線(xiàn)溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
創(chuàng)新互聯(lián)Python教程:python Tkinter模塊是什么

說(shuō)明

1、Tkinter模塊是python的標(biāo)準(zhǔn)TkGUI工具包的接口。

2、Tk和Tkinter可以在大多數(shù)Unix平臺(tái)下使用,也可以應(yīng)用于Windows和Macintosh系統(tǒng)。

Tk8.0后續(xù)版本可以實(shí)現(xiàn)本地窗口風(fēng)格,在絕大多數(shù)平臺(tái)上運(yùn)行良好。

實(shí)例

import tkinter
import time
import threading
from random import random
from tkinter import messagebox as tkMessageBox
 
 
class choujiang:
    # 初始化魔術(shù)方法
    def __init__(self):
        # 準(zhǔn)備好界面
        self.root = tkinter.Tk()
        self.root.title('lowB版轉(zhuǎn)盤(pán)')
        self.root.minsize(300, 300)
        # 聲明一個(gè)是否按下開(kāi)始的變量
        self.isloop = False
        self.newloop = False
        self.value = []
        # 調(diào)用設(shè)置界面的方法
        self.setwindow()
        self.root.mainloop()
 
 
    # 界面布局方法
    def setwindow(self):
        # 開(kāi)始停止按鈕
     self.btn_start = tkinter.Button(self.root, text='start/stop', command=self.newtask)
     self.btn_start.place(x=125, y=125, width=70, height=70)
 
 
     self.btn1 = tkinter.Button(self.root, text='1', bg='red')
     self.btn1.place(x=20, y=20, width=50, height=50)
 
 
     self.btn2 = tkinter.Button(self.root, text='2', bg='white')
     self.btn2.place(x=90, y=20, width=50, height=50)
 
 
     self.btn3 = tkinter.Button(self.root, text='3', bg='white')
     self.btn3.place(x=160, y=20, width=50, height=50)
 
 
     self.btn4 = tkinter.Button(self.root, text='3', bg='white')
     self.btn4.place(x=230, y=20, width=50, height=50)
 
 
     self.btn5 = tkinter.Button(self.root, text='3', bg='white')
     self.btn5.place(x=230, y=90, width=50, height=50)
 
 
     self.btn6 = tkinter.Button(self.root, text='2', bg='white')
     self.btn6.place(x=230, y=160, width=50, height=50)
 
 
     self.btn7 = tkinter.Button(self.root, text='1', bg='white')
     self.btn7.place(x=230, y=230, width=50, height=50)
 
 
     self.btn8 = tkinter.Button(self.root, text='3', bg='white')
     self.btn8.place(x=160, y=230, width=50, height=50)
 
 
     self.btn9 = tkinter.Button(self.root, text='2', bg='white')
     self.btn9.place(x=90, y=230, width=50, height=50)
 
 
     self.btn10 = tkinter.Button(self.root, text='3', bg='white')
     self.btn10.place(x=20, y=230, width=50, height=50)
 
 
     self.btn11 = tkinter.Button(self.root, text='1', bg='white')
     self.btn11.place(x=20, y=160, width=50, height=50)
 
 
     self.btn12 = tkinter.Button(self.root, text='3', bg='white')
     self.btn12.place(x=20, y=90, width=50, height=50)
 
 
      # 將所有選項(xiàng)組成列表
     self.girlfrends = [self.btn1, self.btn2, self.btn3, self.btn4, self.btn5, self.btn6, self.btn7, self.btn8,
                         self.btn9, self.btn10, self.btn11, self.btn12]
 
 
    def rounds(self):
        # 判斷是否開(kāi)始循環(huán)
        if self.isloop == True:
            return
        # 初始化計(jì)數(shù) 變量
        i = 0
        # 死循環(huán)
        while True:
            if self.newloop == True:
                self.newloop = False
                self.value = self.girlfrends[i - 1]['text']
                if self.value =='1':
                    tkMessageBox.showinfo( "Winning Result", "恭喜獲得一等獎(jiǎng) !'")
                if self.value == '2':
                    tkMessageBox.showinfo("Winning Result", "恭喜獲得二等獎(jiǎng) !")
                if self.value == '3':
                    tkMessageBox.showinfo("Winning Result", '恭喜獲得三等獎(jiǎng)!')
                return
            # 延時(shí)操作
            time.sleep(0.1)
            # 將所有的組件背景變?yōu)榘咨?            for x in self.girlfrends:
                x['bg'] = 'white'
            # 將當(dāng)前數(shù)值對(duì)應(yīng)的組件變色
            self.girlfrends[i]['bg'] = 'red'
            # 變量+1
            i += 1
            # 如果i大于索引直接歸零
            if i >= len(self.girlfrends):
                i = 0
    # 建立一個(gè)新線(xiàn)程的函數(shù)
    def newtask(self):
        if self.isloop == False:
            # 建立線(xiàn)程
            t = threading.Thread(target=self.rounds)
            # 開(kāi)啟線(xiàn)程運(yùn)行
            t.start()
            # 設(shè)置循環(huán)開(kāi)始標(biāo)志
            self.isloop = True
        elif self.isloop == True:
            self.isloop = False
            self.newloop = True
#轉(zhuǎn)盤(pán)效果
c = choujiang()

以上就是python Tkinter模塊的介紹,希望對(duì)大家有所幫助。更多Python學(xué)習(xí)指路:創(chuàng)新互聯(lián)python教程

本文教程操作環(huán)境:windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。


網(wǎng)站名稱(chēng):創(chuàng)新互聯(lián)Python教程:python Tkinter模塊是什么
網(wǎng)站地址:http://www.5511xx.com/article/cocphdd.html