Python Forum
[Tkinter] Selected radio button in push button in Tkinter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Selected radio button in push button in Tkinter
#1
my question here

my code here
Hello everyone i am learning about Python GUI stuff,

I have to use 4 radio buttons and a push button.
I created following code for the same.
import Tkinter as tk
from Tkinter import *
import ttk

root = tk.Tk()
root.title("GUI")
root.geometry("300x200")


#####################___________ Profile-1 ___________#####################    
def Profile_1():
   print('Profile 1 selected')

#####################___________ Profile-2 ___________#####################  
def Profile_2():
   print('Profile 2 selected')

#####################___________ Profile-3 ___________#####################  
def Profile_3():
   print('Profile 3 selected')
#####################___________ Profile-4 ___________#####################          
def Profile_4():
   print('profile 4 selected')


def serial_port():
   global var
   print('It comes in to push button menu')
   x = Profile_sel_1.selection_get()
   print(x)
   
var = IntVar()
#Button to show selected profile to assign FTW
Profile_sel_1=Radiobutton(root, text='Profile Selection_1',variable =var, value =1,command = Profile_1,width = 20)
Profile_sel_2=Radiobutton(root, text='Profile Selection_2',variable =var, value =2,command = Profile_2,width = 20)
Profile_sel_3=Radiobutton(root, text='Profile Selection_3',variable =var, value =3,command = Profile_3,width = 20)
Profile_sel_4=Radiobutton(root, text='Profile Selection_4',variable =var, value =4,command = Profile_4,width = 20)
#Button to show entered reg values and data in it
ser_port_btn=Button(root, text='ENTER',command = serial_port,relief="flat",background="#ccc",width=20)
Profile_sel_1.grid(row=1,column = 5)
Profile_sel_2.grid(row=2,column = 5)
Profile_sel_3.grid(row=3,column = 5)
Profile_sel_4.grid(row=4,column = 5)
ser_port_btn.grid(row = 7, column = 3)

root.mainloop()
But When Profile_sel_1 is active high that time function inside it should be used after pressing push button.
Reply


Messages In This Thread
Selected radio button in push button in Tkinter - by prashantfunde91 - Jun-11-2017, 08:15 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] TKinter Remove Button Frame Nu2Python 8 1,015 Jan-16-2024, 06:44 PM
Last Post: rob101
  tkinter - touchscreen, push the button like click the mouse John64 5 869 Jan-06-2024, 03:45 PM
Last Post: deanhystad
  [Tkinter] Search data in treeview without search button TomasSanchexx 3 1,623 Aug-12-2023, 03:17 AM
Last Post: deanhystad
  Centering and adding a push button to a grid window, TKinter Edward_ 15 4,863 May-25-2023, 07:37 PM
Last Post: deanhystad
  [Tkinter] Is there a way to determine if a radio button has been selected? TWB 5 5,081 Jan-31-2023, 09:44 AM
Last Post: Vadanane
  [Tkinter] [split] I want to add a code to the "Save" button to save the data entered LOO 1 1,973 Jan-23-2023, 05:31 PM
Last Post: deanhystad
  [Tkinter] Trying to add data into a shelf from a submit button TWB 8 1,863 Jan-06-2023, 11:30 PM
Last Post: TWB
  [Tkinter] how to make label or button not visible with the place method? nowayj63 2 2,820 Jan-03-2023, 06:29 PM
Last Post: Yoriz
Question [Tkinter] How to make split button? teknixstuff 2 1,074 Jan-03-2023, 06:21 PM
Last Post: Yoriz
  [PyQt] start and stop websocket-client using button GUI zinho 5 2,484 Dec-27-2022, 06:06 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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