码迷,mamicode.com
首页 > 编程语言 > 详细

python 制作GUI页面以及多选框

时间:2020-06-09 18:52:13      阅读:99      评论:0      收藏:0      [点我收藏+]

标签:工作   width   bottom   dial   variable   entry   打开文件   输入   open   

import osimport tkinter as tk
from tkinter import filedialog
from tkinter.scrolledtext import ScrolledText

window = tk.Tk()
window.title(华润万家门店导出)  # 标题
window.geometry(600x500)  # 窗口尺寸

file_path = ‘‘

contents = ScrolledText()
contents.pack(side=tk.BOTTOM, expand=True, fill=tk.BOTH)
# 输入文本框
filename = tk.Entry()
filename.pack(side=tk.LEFT, expand=True, fill=tk.X)


# 打开文件
def open_file():
    global file_path
    global on_hit
    file_path = filedialog.askopenfilename(title=u选择文件, initialdir=(os.path.expanduser(H:/)))  # 这里打开文件 askdirectory(文件夹) 
    print(打开文件:, file_path)
    if file_path is not None:
        filename.insert(tk.INSERT, file_path)
        on_hit = True


on_hit = False


# 工作
def work():
    global on_hit
    if on_hit:
        print(ok)
            elif res == 登陆密码不正确 or res == "用户名不正常":
                print(res)
                var1.set(res)
                return
            else:
                var1.set("下载完毕!")
                return


tk.Button(text=打开文件, command=open_file).pack(side=tk.LEFT)

bt1 = tk.Button(window, text=开始运行, width=15, height=2, command=work)
bt1.place(x=250, y=150)

var1 = tk.StringVar()
label = tk.Label(window, textvariable=var1, bg="blue", font=("Arial", 12), width=25, height=2)
label.place(x=200, y=350)

window.mainloop()  # 显示

制作多选框

import tkinter as tk

# checkButton的内容,多选


window = tk.Tk()
window.title(华润万家门店导出)  # 标题
window.geometry(600x500)  # 窗口尺寸

# tx = tk.Text(window,variable="")
one = tk.IntVar()
two = tk.IntVar()
three = tk.IntVar()

ck_one = tk.Checkbutton(window, text="业务单据", variable=one, offvalue=0, onvalue=1)
ck_two = tk.Checkbutton(window, text="销售日报", variable=two, offvalue=0, onvalue=1)
ck_three = tk.Checkbutton(window, text="每日库存", variable=three, offvalue=0, onvalue=1)

ck_one.pack()
ck_two.pack()
ck_three.pack()

on_hit = False


def work():
    print(one.get(), two.get(), three.get())  # 分别取值
    # global on_hit
    # if on_hit:
    print(ok)


bt1 = tk.Button(window, text=开始运行, width=15, height=2, command=work)
bt1.place(x=250, y=150)

tk.mainloop()

 

python 制作GUI页面以及多选框

标签:工作   width   bottom   dial   variable   entry   打开文件   输入   open   

原文地址:https://www.cnblogs.com/wukai66/p/13074361.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!