2

I used below approach from this post to hide GUI elements which works very well:

import PySimpleGUIQt as sg

layout = [          
         [sg.Checkbox('Module Selection', default = False, change_submits= True, key = '_checkbox1_', size=(15,1)),
         sg.Text('Module(.xlsx)', size = (15,0.5), auto_size_text = True, justification = 'right', key = '_moduletext_')]
         ]


window = sg.Window('A2L', layout, icon = u"icon\\index.ico", auto_size_buttons = False).Finalize()  
window.Element('_moduletext_').Update(visible = False) #makes the element invisible
values_dict={}


while True:  # Event Loop            
    button, values_dict = window.Read()

    if values_dict['_checkbox1_']:
        window.Element('_moduletext_').Update(visible = True)

The problem here is that If i replace the checkbox with a radio button then same code doesnt hide the gui element dyanmically.Below is the code with Radio button:

import PySimpleGUIQt as sg

layout = [          
             [sg.Radio('Module Selection','RADIO' default = False, enable_events = True, key = '_radio1_', size=(15,1)),
             sg.Text('Module(.xlsx)', size = (15,0.5), auto_size_text = True, justification = 'right', key = '_moduletext_')]
             ]


window = sg.Window('A2L', layout, icon = u"icon\\index.ico", auto_size_buttons = False).Finalize()  
window.Element('_moduletext_').Update(visible = False) #makes the element invisible
values_dict={}


while True:  # Event Loop            
        button, values_dict = window.Read()

        if values_dict['_radio1_']:
            window.Element('_moduletext_').Update(visible = True)

How to hide the element using Radio button in pysimpleGUIqt?

uhoh
  • 3,713
  • 6
  • 42
  • 95
Anudocs
  • 686
  • 1
  • 13
  • 54
  • Radio Buttons usually have more than 1. Unsure about the behavior of a single Radio. A single Checkbox is fine, but not a radio button. – Mike from PSG Jul 12 '19 at 13:56
  • I think you've hit either a bug or the Radio Buttons enable_events isn't implemented. I thought it was but may not be on Qt. I'll make it a priority and look at the code. – Mike from PSG Jul 12 '19 at 18:43
  • @MikeyB I've just quoted you in [Is there a way for PySimpleGUI Radio Buttons to generate events when changed?](https://stackoverflow.com/q/60846217/3904031) – uhoh Mar 25 '20 at 09:41
  • Great.... these need to be asked on the GitHub. – Mike from PSG Mar 25 '20 at 13:50
  • This page literally has the answer to the other post you made and linked here. The messages don't seem to be getting through. – Mike from PSG Mar 25 '20 at 14:00

1 Answers1

1

Enabling events for Radio Buttons was not implemented in PySimpleGUIQt yet. Just finished the code for it and tried your code against it.

You need to download the PySimpleGUIQt.py file on the project's GitHub site and place it in your application's folder.

Mike from PSG
  • 5,312
  • 21
  • 39
  • Thanks for updating the code. I got an error using your code which i explained here : https://stackoverflow.com/questions/57034955/how-to-create-gui-from-the-pysimpleguiqt – Anudocs Jul 15 '19 at 07:21
  • I don't recommend posting these kinds of problems here. Post them on the project's GitHub site. You'll get quicker support and can more easily post your code and images. – Mike from PSG Jul 15 '19 at 21:56