Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter Checkbox
#1
Hello ultimately this GUI will wrap arcs onto cylinders. Continuous linear+rotary. I have the math done (requires touch improvement). Cannot get check button to position properly. PSN_01 ideally below TBE_DIA. When complete ten positions total. Logic is if PSN_01 checked calculate DRL (drill start) + check button on centre or off centre. RGH (rough with endmill if DRL does not complete. FIN (finish with endmill because continuous linear+rotary output is normal to wrap diameter). Features are perpendicular to rotary. Appreciate any help. Cheers.
from datetime import datetime
import math
import sys
import tkinter as tk



def save():
    print(tbe_dia.get())
    stdoutOrigin=sys.stdout 
    sys.stdout = open(nc_get.get()+".txt", 'w')  
    now = datetime.now()
    now_str = now.strftime("%H:%M")
    #now_day = now.strftime("%Y.%m.%d")
    #now_str = now.strftime("%H:%M:%S")
    doy = datetime.now().timetuple().tm_yday
    if doy < 100:
        now_doy = str(doy)
        now_doy = str("0"+(now_doy))
    else:
        now_doy = str(doy)
    print("%")
    print()
    print("O"+(nc_get.get()))
    print()
    print("(PROVEN "+(now_str)+":"+(now_doy)+")")
    print()
    sys.stdout.close()
    sys.stdout=stdoutOrigin

gui = tk.Tk()

os_wdh = gui.winfo_screenwidth()
os_hgt = gui.winfo_screenheight()
tk_wdh = 500
tk_hgt = 500
xn_cnt = (os_wdh/2)-(tk_wdh/2)
yn_cnt = (os_hgt/2)-(tk_hgt/2)

gui.title('PRJ_ARC')
gui.geometry('%dx%d+%d+%d' % (tk_wdh, tk_hgt, xn_cnt, yn_cnt))
gui.resizable(width=False, height=False)

nc_get = tk.Entry(gui, width=10)
#nc_get.pack#(fill=tk.NONE)
nc_get.place(x=360, y=25) 

nc_run = tk.Button(gui, text='!', width=5, command=save)
#nc_run.pack()
nc_run.place(x=438, y=22) 

tbe_dia = tk.Entry(gui, width=5)
#tbe_dia.pack#(fill=tk.NONE)
tbe_dia.place(x=25, y=30) 

tbe_lbl = tk.Label(gui, text = "TBE_DIA")
#tbe_lbl.pack#(fill=tk.NONE)
tbe_lbl.place(x=65, y=30) 


def psn_01():
    print('psn_01 :', chk_v01.get())

chk_v01 = tk.IntVar()

btn_01 = tk.Checkbutton(gui, text = "PSN_01",
                        variable = chk_v01,
                        command = psn_01)
btn_01.pack()
                    
dia_01 = tk.Entry(gui, width=10)
dia_01.place(x=100, y=55)

lbl_01 = tk.Label(gui, text = "DIA")
lbl_01.place(x=170, y=55)

xpn_01 = tk.Entry(gui, width=10)
xpn_01.place(x=200, y=55)

lbl_01 = tk.Label(gui, text = "XPN")
lbl_01.place(x=270, y=55)

apn_01 = tk.Entry(gui, width=10)
apn_01.place(x=300, y=55)

lbl_01 = tk.Label(gui, text = "APN")
lbl_01.place(x=370, y=55)
 
drl_lbl = tk.Label(gui, text = "DRL")
drl_lbl.place(x=50, y=90)

drl_01 = tk.Entry(gui, width=10)
drl_01.place(x=100, y=90)

drl_dia = tk.Label(gui, text = "DIA")
drl_dia.place(x=170, y=90)

gui.mainloop()
Reply
#2
btn_01.place(x=15,y=60)
logic example:
cb_val= chk_v01.get()
if cb_val == 1:
    #do something
else:
    #do the other thing or skip the else
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] choose checkbox devilonline 1 1,239 Feb-17-2023, 01:23 PM
Last Post: Axel_Erfurt
  [Tkinter] Dynamic checkbox treeview issue OogieM 8 4,820 Mar-20-2022, 02:10 PM
Last Post: OogieM
  tkinter change the text of the checkbox zazas321 1 3,759 Sep-17-2021, 06:19 AM
Last Post: zazas321
  How to get the value of a checkbox scratchmyhead 4 2,995 May-14-2020, 02:56 PM
Last Post: scratchmyhead
  Tkinter checkbox value scratchmyhead 5 3,594 May-09-2020, 11:44 PM
Last Post: menator01
  TreeviewWith CheckBox issac_n 1 7,685 Mar-08-2020, 06:51 AM
Last Post: shamnadinn
  [Tkinter] Unable to create checkbox and select at run time tej7gandhi 5 4,585 May-05-2019, 04:57 PM
Last Post: tej7gandhi
  [PyQt] PyQt4 handle dynamic checkbox click littleGreenDude 1 6,538 Dec-27-2018, 09:17 PM
Last Post: littleGreenDude
  [Tkinter] Completing Action when CheckBox is Checked Anysja 2 7,891 Aug-02-2018, 04:38 PM
Last Post: Anysja
  Displaying error in QTableview and with Checkbox in Column under macOsX nieselfriem 1 5,385 Mar-19-2017, 10:43 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020