Familiar with the Tkinter graphics package in Python--(write a parameter calculator)

Source: Internet
Author: User
Tags pack
There's a basic understanding of Python, always want to do something have been struggling to find a good practice, this does not work, need to do the project plan, the project needs to be based on 3 known parameters to calculate other parameters, as well as the stability of the parameters of the state, so intend to use this to familiarize yourself with Python, Although this program is not very robust, and did not encapsulate the parameters, but let me basically familiar with the Tkinter this GUI as a Third-party package. Does not say, directly on the procedure, has wants the detailed understanding direct DMS to be good.

#coding: Utf-8 from tkinter import * traitlets.config.application import Catch_config_error root = Tk () root.title (' Ball  Grinding machine parameter calculation ') frame = frame (root) frame.pack () Framer = FRAME (root) framer.pack () Frame1 = FRAME (root) frame1.pack () Frame3 = FRAME (root) frame3.pack () Frame4 = FRAME (root) frame4.pack () Frame2 = FRAME (root) frame2.pack () L1 = Label (frame, text= "1 Quality") l1.pack (side = left) E1 = Entry (frame, BD =5) e1.pack (side = left) L2 = Label (frame, text= "2 Quality") L2.pack (si De = left) E2 = Entry (frame, BD =5) e2.pack (side = left) L3 = Label (frame, text= "3 quality") l3.pack (side = left) E3 = Entry (f Rame, BD =5) e3.pack (side = left) L4 = Label (Frame, text= "Volume (L)") l4.pack (side = left) E4 = Entry (frame, BD =5) e4.inser T (end, ' m ') e4.pack (side = left) #-----------------------------------------------RG = Label (framer, text= "1 density") RG.PA
CK (side = left) Rgg = Entry (framer, BD =5) Rgg.insert (end, ' 7900 ') rgg.pack (side = left) RW = Label (framer, text= "2 density") Rw.pack (side = left) RWW = Entry (framer, BD =5) Rww.insert (end, ' 2200 ') rww.pack (side = left) rs = Label (framer, text= "3 density") rs.pack (side = Left  rss = Entry (framer, BD =5) Rss.insert (end, ' 1000 ') rss.pack (side = left) JK = Label (framer, text= "air rate") jk.pack (side = left) Jkk = Entry (framer, BD =5) Jkk.insert (end, ' 0.38 ') jkk.pack (side = left) #---------------------------------------- -------L5 = Label (frame1, text= "12 ratio") l5.pack () V5text = Stringvar () v5 = Entry (frame1, Text = v5text) v5.pack () L6 = L Abel (frame1, text= "123") l6.pack () V6text = Stringvar () V6 = Entry (frame1, Text = v6text) v6.pack () L7 = Label (frame1, 
text= "filling rate") l7.pack () V7text = Stringvar () V7 = Entry (frame1, Text = v7text) v7.pack () L8 = Label (frame1, text= "fill rate 12") L8.pack () V8text = Stringvar () V8 = Entry (frame1, Text = v8text) V8.pack () var = stringvar () label = label (Frame3, T Extvariable=var, relief=raised) var.set ("---------------------------------------- Constant speed of the load-------------------------------------------") label.pack() L9 = Label (Frame4, text= "1 Load") l9.pack () V9text = Stringvar () V9 = Entry (frame4, Text = v9text) v9.pack () L10 = La Bel (Frame4, text= "2 Load") l10.pack () V10text = Stringvar () V10 = Entry (frame4, Text = v10text) v10.pack () L11 = Label (fra  Me4, text= "3 load") l11.pack () V11text = Stringvar () V11 = Entry (frame4, Text = v11text) v11.pack () def cmp_f_mw (LB, LW,  LM, Vmill, MG, MW, Ms,cont): V5text.set (') V5text.set (lm/(LM+LW)) def cmp_f_mb (LB, LW, LM, Vmill, MG, MW,  MS, Cont): V6text.set (') V6text.set ((LM/MW)/((cont/(1-cont)) (LB/MG)) def cmp_f_bf (LB, LW, LM, Vmill, MG, MW, MS, CONT): F_BF = ((cont/(1-cont) * (LB/MG)) + (LB/MG))/vmill v7text.set (') V7text.set (F_BF) def CMP_F_BMW (l 
    B, LW, LM, Vmill, MG, MW, MS, cont): BMW = (LM/MW + LW/MW + lb/mg)/vmill v8text.set (") v8text.set (BMW) Try:  Def comput (): lb = e1.get () LW = E2.get () lm = E3.get () Vmill = E4.get () mg = Rgg.get () MW =Rww.get () ms = Rss.get () cont = Jkk.get () lb = float (lb) LW = float (LW) L m = float (lm) Vmill = float (vmill) mg = Float (mg) mw = float (MW) ms = Float (MS) CO NT =float (cont) #计算1 CMP_F_MW (LB, LW, LM, Vmill, MG, MW, MS, cont) #计算2 Cmp_f
        _MB (LB, LW, LM, Vmill, MG, MW, MS, cont) #计算3 CMP_F_BF (LB, LW, LM, Vmill, MG, MW, MS, Cont) #计算充填率 CMP_F_BMW (LB, LW, LM, Vmill, MG, MW, MS, cont) except Exception:print ' Jajjaja ' B = Button (fram e2, Text = "Compute load parameters", command = comput) B.pack (side = left) def cmp_wl_fh (LB, LW, LM, Vmill, MG, MW, MS, Cont, LQB, MKND, JZTC, TC): LM = (Tc*vmill)/((1/MW) + ((1-MKND)/(MW*MKND) + ((1-cont)/cont)) * (1/(LQB*MW)) V11text.set (")". Set (LM) def cmp_gq_fh (LB, LW, LM, Vmill, MG, MW, MS, Cont, LQB, MKND, JZTC, tc): LBC = (TC *vmill*mg* ((1-cont)/cont) )/(lb+ (1-LW)/lw) * (mw*lb)/MW + ((1-cont)/cont) V9text.set (") V9text.set (LBC) def cmp_sh_fh (LB, LW, LM, Vmill, MG, MW, MS, Cont, LQB, MK 
    nd, JZTC, tc): Water = (Tc*vmill)/(mknd/(mw* (1-MKND)) +1/ms + ((1-cont) *mknd)/(cont*mw*lqb* (1-MKND))) V10text.set (")"

    V10text.set (water) def computnow (): LQB = V5.get () mknd = V6.get () JZTC = V7.get () TC = V8.get () LQB = float (lqb) mknd = float (mknd) JZTC = float (JZTC) TC = FLOAT (TC) lb = e1.get () LW = e2.ge
    
    T () LM = E3.get () Vmill = E4.get () mg = Rgg.get () MW = Rww.get () ms = Rss.get () cont = Jkk.get () LB = float (lb) LW = float (LW) lm = float (lm) Vmill = float (vmill) mg = Float (mg) mw = float (MW ms = FLOAT (ms) cont =float (cont) #1负荷 cmp_wl_fh (LB, LW, LM, Vmill, MG, MW, MS, CONT,LQB,MKND,JZ TC,TC) #2负荷 cmp_gq_fh (LB, LW, LM, Vmill, MG, MW, MS, CONT,LQB,MKND,JZTC,TC) #3负荷 cmp_sh_fh (LB, LW, l M, Vmill, MG, MW, MS,CONT,LQB,MKND,JZTC,TC) B = button (frame2, Text = "Calculate load during normal operation", command = Computnow) B.pack (side = left) root.mainl OOP ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.