Python Forum
[Tkinter] Getting the Respective Value
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Getting the Respective Value
#1
from tkinter import *
import Pmw

class Message:
    def __init__(self):
        self.root = Tk()
        self.build_Message()
        self.root.mainloop()

    def build_Message(self):
        self.entry = self.combobox =  None
        self.messages = {'Help': 'Save current file',
                         'Userevent': 'Saving file "foo"',
                         'Busy': 'Busy deleting all files from file system ...',
                         'Systemevent': 'File "foo" saved',
                         'Usererror': 'Invalid file name "foo/bar"',
                         'Systemerror': 'Failed to save file: file system full',
                         }
        self.combobox = Pmw.ComboBox(self.root, labelpos=N, label_text='Message Type',
                                dropdown=False,
                                listbox_relief=SUNKEN,
                                listbox_font = 'tahoma 10 bold',
                                scrolledlist_items = self.messages.keys(),
                                selectioncommand = self.enter,
                                listbox_background='grey')
        self.combobox.pack(fill=X,padx=5,pady=5)
        self.entry = Pmw.MessageBar(self.root,labelpos=W,label_text='Status:',entry_width=30)
        self.entry.pack(fill=X,padx=5,pady=5)

    def enter(self,event):
        self.combobox.configure(label_text=event)
        for k,v in self.messages.items():
            self.entry.helpmessage(v)

if __name__=="__main__":
    Message()
Please how can I click on the scrolled list item 'keys' and get the respective 'values' from 'self.message' dictionary variable displayed in my Pmw MessageBar Widget. Thanks
Reply


Messages In This Thread
Getting the Respective Value - by Vicolas - Feb-13-2019, 12:41 PM
RE: Getting the Respective Value - by woooee - Feb-13-2019, 05:55 PM
RE: Getting the Respective Value - by Vicolas - Feb-14-2019, 02:57 PM
RE: Getting the Respective Value - by woooee - Feb-14-2019, 10:15 PM
RE: Getting the Respective Value - by Vicolas - Feb-15-2019, 05:53 PM

Forum Jump:

User Panel Messages

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