ERP-库存与存货-公告111


from tkinter import *                                                               #导入tkinter
from tkinter import messagebox                                                      #引入弹出框
#from typing import Any, Union
import pymysql                                                                       #导入pymysql
from pymysql.cursors import Cursor                                                  #导入游标
from hashlib import sha1                                                            #导入hashlib,引用函数
import tkinter as tk
from PIL import Image                                                                #图像缩放
from tkinter import Scrollbar
from tkinter import ttk                                                              # 导入内部包
from tkinter.ttk import Treeview


class TestUI(object):
    def __init__(self, master):
        self.conn = pymysql.Connect(
            host='localhost',
            port=3306,
            user='root',
            passwd='12345',
            db='库存与存货系统',
            charset="utf8"
        )
        self.root = master
        self.create_frame()

    def create_frame(self):
        '''
        create frame,left and right and right1
        '''
        self.frm_left = tk.LabelFrame(self.root)
        self.frm_right = tk.LabelFrame(self.root)
        self.frm_right1 = tk.LabelFrame(self.root)

        self.frm_left.grid(row=0, column=0, sticky="wesn")
        self.frm_right.grid(row=0, column=1, sticky="wesn")
        self.frm_right1.grid(row=0, column=2, sticky="wesn")

        self.create_frm_left()
        self.create_frm_right()
        self.create_frm_right1()

    def create_frm_left(self):
        self.frm_left_label = tk.Label(self.frm_left,
                                       text="日期(20180701表示:\n2018年07月01日的通知\n其余时间以此类推!)")
        self.frm_left_listbox = tk.Listbox(self.frm_left)
        self.frm_left_btn = tk.Button(self.frm_left,
                                      text="查看",bg="white",command=self.check)



        self.frm_left_label.grid(row=0, column=0, padx=60, pady=40, sticky="w")
        self.frm_left_listbox.grid(
            row=1, column=0, padx=60, pady=40, sticky="wesn")
        self.frm_left_btn.grid(row=2, column=0, padx=30, pady=40, sticky="wesn")


        for i in range(20180701,20180710):
            self.frm_left_listbox.insert("end", i)


    def check(self):                                                                     #显示通知

        myText = self.frm_right_canvas.create_text(200, 100, text='' )
        value=self.frm_left_listbox.get(1)
        #print(value) #测试
        cursor = self.conn.cursor()
        cursor.execute("select message from inform where `date`='%s'" % value)

        self.conn.commit()
        results=cursor.fetchall()
        #print(results)                                                                        #测试已经采集到数据
        message=results
        val={}
        val['message'] = StringVar()
        #print(results )                                                                       #二测
                                                                           #测试ID
        myText = self.frm_right_canvas.create_text(200, 100, text='%s' % results)

        cursor.close()
        self.conn.close()







    def create_frm_right(self):
        self.frm_right_canvas = tk.Canvas(self.frm_right, bg="white")

        self.frm_right_canvas.grid(row=4, column=0, padx=60, pady=100, sticky="wesn")

        #self.frm_right_btn = tk.Button(self.frm_right,
        #                              text="退出", bg="white")
        #self.frm_right_btn.grid(row=2, column=1, padx=60, pady=40, sticky="wesn")
        #self.frm_right_canvas.grid(row=0, column=60, padx=60, pady=40, sticky="wesn")

    def create_frm_right1(self):
        self.frm_right1_canvas = tk.Canvas(self.frm_right1)
        myText = self.frm_right1_canvas.create_text(200, 100, text='\n\n关于公告!\n请密切关注系统通告,'
        '\n所有税率、库存量、价格\n......均以公告为准。\n因未及时查看公告,\n带来的一切后果自负')

        self.frm_right1_canvas.grid(row=4, column=1, padx=20, pady=100, sticky="wesn")



'''
main loop
'''
root = tk.Tk()
root.title("库存与存货管理系统-通告")
root['width'] = 300
root['height'] = 400
#root['bg'] = 'pink'
root.geometry('1200x600-100-100')
TestUI(master=root)
root.resizable(False, False)
root.mainloop()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值