Python Forum
[Tkinter] tkinter, dropdowns with changing options
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] tkinter, dropdowns with changing options
#3
from Tkinter import *
import Tkinter as ttk
from ttk import *
 
root = Tk()
root.title("puppet app")
 
# Add a grid
mainframe = Frame(root)
mainframe.grid(column=0,row=0, sticky=(N,W,E,S) )
mainframe.columnconfigure(0, weight = 1)
mainframe.rowconfigure(0, weight = 1)
mainframe.pack(pady = 100, padx = 100)
 
tkvar = StringVar(root)
 
choices = { 'Package','file'}
tkvar.set('Package') # set the default option
 
popupMenu = OptionMenu(mainframe, tkvar, *choices)
Label(mainframe, text="Choose an option").grid(row = 1, column = 1)
popupMenu.grid(row = 2, column =1)
 

def change_dropdown(*args):
    print( tkvar.get() )
 

tkvar.trace('w', change_dropdown)
 
root.mainloop()
So, when someone selects "package", i need another drop down box to appear or another box to have its options change to the package specific attributes.

This is a puppet manifest in its normal form:
package { 'apache2':
  require => Exec['apt-update'],        # require 'apt-update' before installing
  ensure => installed,
}
So the "require" attribute for package, isnt necessary for the 'file' option.

So at the minute, its almost nothing. just a small GUI box, with one drop down.
I'm thinking the options may change using an IF statement? but i'm not sure how to do it.

Any help appreciated.
Reply


Messages In This Thread
RE: tkinter, dropdowns with changing options - by Sheepykins - Oct-15-2018, 10:57 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Trouble changing Font within tkinter frame title AnotherSam 1 4,155 Sep-30-2021, 05:57 PM
Last Post: menator01
  [Tkinter] Tkinter delete values in Entries, when I'm changing the Frame robertoCarlos 11 5,883 Jul-29-2020, 07:13 PM
Last Post: deanhystad
  changing tkinter label from thread nanok66 3 7,398 Jun-07-2020, 01:37 AM
Last Post: nanok66
  [Tkinter] changing title text to bold in tkinter Kumarkv 2 8,788 May-09-2020, 10:41 PM
Last Post: Larz60+
  [Tkinter] Create and remove advanced options PengEng 4 2,393 Apr-09-2020, 11:26 AM
Last Post: PengEng

Forum Jump:

User Panel Messages

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