Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Gui Button click
#1
Hi.

I am making gui application using Qt4, but the whole signals and slots thing seems way too complex, so I suspect it is my coding. But it appears that using the new signals and slots method, I can't work out how to actually connect to a method directly, I seem to always have to go through another method first, otherwise I get a:
bool has no attribute 'whatever'
When I haven't actually coded a single boolean variable in the whole application.

Here is an example:
class MainUiWindow( QtGui.QMainWindow ):
    def __init__(self, parent = None):
        super(MainUiWindow, self).__init__(parent)

    def exampleMethod( self ):
        self.example = aWidget()
        self.example.show()
        self.example.ui_okbtn_act.clicked.connect(self.pointlessMethod)

    def pointlessMethod( self ):
        UiWidget.wantedMethod()

class UiWidget( object ):
    def wantedMethod( self ):
        print('Hello World')
This seems all very good and well untill you have a few things, so now I have 13 methods in my main window class, 5 of these are purely methods that go from the button click to the method I want to use as a result of the button click.

There must be a better more compact way of doing this?
Reply
#2
I haven't used Qt in a long while, but when I used it, there was a tutorial on the designer that did a really good job on explaining signal and slots.
I don't know what the name was, or where to find it. But if you can, I think you'll like it.
Something to look for.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter - touchscreen, push the button like click the mouse John64 5 829 Jan-06-2024, 03:45 PM
Last Post: deanhystad
  Figure Gets Larger Every time I click a show button joshuagreineder 2 1,325 Aug-11-2022, 06:25 AM
Last Post: chinky
  [Tkinter] Modify Class on Button Click KDog 4 3,946 May-11-2021, 08:43 PM
Last Post: KDog
  [Tkinter] Button click problem using OOP JohnB 5 3,597 Oct-21-2020, 12:43 PM
Last Post: JohnB
  tkinter | Button color text on Click Maryan 2 3,359 Oct-09-2020, 08:56 PM
Last Post: Maryan
  Closing window on button click not working kenwatts275 4 3,746 May-03-2020, 01:59 PM
Last Post: deanhystad
  [Tkinter] Checking button click in Tkinter GalaxyCoyote 3 7,360 Oct-20-2019, 03:28 AM
Last Post: GalaxyCoyote
  [PyQt] Problem how to click a button inside a group box? mart79 2 3,433 Aug-05-2019, 01:21 PM
Last Post: mart79
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 4,997 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  [Tkinter] Tkinter window pop up again when i click button Orimura_Sandy 1 3,324 May-12-2019, 08:17 PM
Last Post: joe_momma

Forum Jump:

User Panel Messages

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