Working with windows in Gtk2-Perl - perl

I am working on a Gtk2-Perl project, where I have to create a GUI. Now I have to do one thing, that whenever the user selects 'Single' Radio button, or the 'Multiple' Radio button, either a seperate screen should come up, or the content of the same window should change.
Ex: when user selects Single: He should be having 4 buttons, But when he selects Multiple: he should be having 10 buttons, and some more widgets.
Can someone help me in creating a pop up window, which will contain respective widgets, on selection of appropriate radio button. Or any help regarding, callbacks where we can add buttons and widgets.

You could have a look at these tutorials for a starting point.
http://gtk2-perl.sourceforge.net/doc/gtk2-perl-tut/
http://soliton.ae.gatech.edu/people/jcraig/classes/ae6382/perl/gtkperl-tutorial/html/index.html

Related

Assign Radio Group to Radio Buttons

I have several radio buttons
I need to assign a radio group to it so that only one radio button is selectable at a time.There is no radio group option.I have tried
Assigning a single action outlet to all buttons
Putting all buttons in a custom view
None of this works.
In the old days, NSMatrix was the class that provided the radio group behavior. If you look up the docs for that class, you'll find the following note:
Use of NSMatrix is discouraged in apps that run in macOS 10.8 and later. If you need to create a radio button group in an app that runs in macOS 10.8 and later, create instances of NSButton that each specify a button type of NSRadioButton and specify the same action and the same superview for each button in the group.
So there are three things that all need to be true at the same time for this to work:
Your buttons all have to share the same superview.
Your buttons all have to have the same action.
Your buttons need to have their button type set to NSRadioButton.
I tried this out just now. I created a button in a view in my storyboard, set it's button type to "Radio" in the Attributes inspector, and assigned an action. Then I duplicated that button several times, and ran the app. The radio behavior worked automatically.
If it's not working for you, I'd start by doing what I did above. Just create a single radio button and set it up with an action. Then duplicate it a few times and test. If that works (it should), then either see if you can use that technique to get what you want, or look at what's different between what you want and what works.

Access Menu sub form - No default Tab stop

I have a main form...imagine that...that for most of my users will be the only form they use. Naturally, it contains tabs with sub forms.
I have a navigation sub form on the left side of this form that changes based on the user's rights level. Currently, this sub form is all buttons...and 1 always is selected as the default tab stop for that form.
I don't want to highlight any of them at first...and I can remove the highlight by switching off Tab Stops for all buttons. However, I'm not sure that I want to remove that functionality all together...and it still highlights a button. I'd just like for there to not be a default button highlighted.
As you can see, Add Course is 'selected'. I can't seem to find the correct terminology to search for a way to do this. I tried using a smaller button set behind another button, but since it has the focus, it moves to the front. Using a text field with the same colors as the background shows the cursor in a random, blank area...not visually ideal.
I'm sure that there is someone here clever enough to have this figured out. Please enlighten me. I don't care if this can be handled in VBA code or through design view.
"Focus" is the word you're looking for - you don't want any visible control to have the focus when opening the form.
The easiest method is an invisible button: create a button with Transparent = True, and an empty OnClick (i.e. the button does nothing, even when accidentally clicked).
Move this button to the top in the Tab Order, so it has the focus when opening the form.
But if your users use TAB to walk through the buttons, there will be one position where the focus disappears (when circling around from the last to first control). I don't know if it will confuse them.
Create a button on the main form itself.
Named is cmdDummyButton with the following GotFocus event code.
Set the tab order property to 0 (ie first)
Make the button transparent.
This will cause no control on the form to have the focus when it starts up.
Private Sub cmdDummyButton_GotFocus()
Static IveHadFocusAlready As Boolean
If Not IveHadFocusAlready Then
Me.cmdDummyButton.Enabled = False
IveHadFocusAlready = True
End If
End Sub
Sweet.

Different form actions depending on button

I have a scroll menu and three different buttons on the page. If one button is clicked, then the form launches a file passing the value selected from the menu. If the 2nd button, and so on for the 3rd, to launch a 2nd or 3rd page. I've tried several theories with Java and have come up empty.

Oracle Button issue

Working on a oracle project. I am new to oracle forms. I am currently using 10g forms. I am successfully able to develop my first form from datablock wizard. It initially contained 10 rows. After that i tried to make a button but 10 buttons show up. All have same name and behave like a single unit but they look like 10 buttons.
http://postimage.org/image/breymi2pn/
Following is the image of buttons which i am getting on form canvas:
The reason for the multiple buttons is that you have added the button to a multi record block. You can fix this problem either by moving the button to a single record control block. If you need to have the button in the multi record block but only want to display one button then you need to set the 'Number of Items displayed' item level property for the button item to 1.

Is there a way to uncheck all radio buttons in a group? (PyGTK)

Is there a way to uncheck all radio buttons in a group with PyGTK? No radio buttons are checked on startup, so I think there must be a way to return them all to that unchecked state.
I agree with Michael, but for the record this can be done.
One way to do this would be to have a hidden radio button that you could activate, which would then cause all the visible ones to be inactive. Quick n' Dirty example:
import gtk
window = gtk.Window()
window.set_default_size(200, 200)
rb1 = gtk.RadioButton()
rb2 = gtk.RadioButton()
rb3 = gtk.RadioButton()
rb2.set_group(rb1)
rb3.set_group(rb2)
rb3.set_active(True)
hbox = gtk.HBox()
hbox.add(rb1)
hbox.add(rb2)
hbox.add(rb3)
button = gtk.Button("Click me")
button.connect("clicked", lambda x: rb3.set_active(True))
hbox.add(button)
window.add(hbox)
window.show_all()
rb3.hide()
gtk.main()
There shouldn't be. By their nature, a radio button group is a 'pick one of many' type of control. From a human perspective, the idea is that one of them is always selected. The framework really should enforce that, so there really shouldn't be a 'none selected' state for the group. The none-selected state of a radio button group (in frameworks where it's possible) is very confusing to users, because that's not a state that they can get the control into.
If you want a 'none selected' state, I'd say you should add a 'none' element to the group, OR chose a different control type that conforms to what you want to do with it.
Looked it up in the source code and set_active simply simulates a click on the button if the new state is different from the old one. The radio button code then checks to see if there is another radio button in the group active and if not, it refuses to change as you noticed.
From what it looks the first radio button should always be set to active when you create the group (as expected). If it doesn't show it is likely a bug, it would be interested to see if radio_button.get_active is True for the first button you create (even if it doesn't show up in the UI).
I agree with Michael Kohne though that you should look into another UI element if you want to make all the radio buttons unselected.
My solution, which is notably not encouraged, Is to have a radio button in the same group that isn't shown on screen.
In Glade you can 'add widget as toplevel' in the context menu of the widget add button. In code I would imaging it's basically just don't add the widget to any displayed gui, or carefully don't .show() it (including .showall() on a parent)