Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8637801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:33:44+00:00 2026-06-12T10:33:44+00:00

So I have been trying to write a GUI using Python 3.3 and PyQt4.

  • 0

So I have been trying to write a GUI using Python 3.3 and PyQt4. I have been through a few tutorials and I still can’t figure out how to have a Checkbox checking and unchecking trigger change in a global variable. I can’t get it to trigger anything for that matter because all the tutorials use methods that wont work for me.

The program is too big to copy here as a whole so I have put together the basic structure of the program surrounding the Checkboxes

import sys
from PyQt4 import QtGui, QtCore

ILCheck = False

class SelectionWindow(QtGui.QWidget):
    def __init__(self, parent=None):
        super(SelectionWindow, self).__init__(parent)

        ILCheckbox = QtGui.QCheckBox(self)
        ILCheckbox.setCheckState(QtCore.Qt.Unchecked)

        MainLayout = QtGui.QGridLayout()
        MainLayout.addWidget(ILCheckbox, 0, 0, 1, 1)
        self.setLayout(MainLayout)

This is where I’m stuck. What I want to do is change the state of ILCheck to True if the ILCheckbox is Checked and change it back to False when its Unchecked. Been working on this pretty much an entire day and none of the tutorials have been much help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:33:46+00:00Added an answer on June 12, 2026 at 10:33 am

    The checkbox emits a stateChanged event when its state is changed (really!). Connect it to an event handler:

    import sys
    
    from PyQt4.QtGui import *
    from PyQt4.QtCore import *
    
    class SelectionWindow(QMainWindow):
        def __init__(self, parent=None):
            super().__init__(parent)
    
            self.ILCheck = False
    
            ILCheckbox = QCheckBox(self)
            ILCheckbox.setCheckState(Qt.Unchecked)
    
            ILCheckbox.stateChanged.connect(self.ILCheckbox_changed)
    
            MainLayout = QGridLayout()
            MainLayout.addWidget(ILCheckbox, 0, 0, 1, 1)
    
            self.setLayout(MainLayout)
    
        def ILCheckbox_changed(self, state):
            self.ILCheck = (state == Qt.Checked)
    
            print(self.ILCheck)
    
    
    if __name__ == '__main__':
      app = QApplication(sys.argv)
      window = SelectionWindow()
    
      window.show()
      sys.exit(app.exec_())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have been trying to write a program in python to read two text
I have been trying to write a bare-bones ping scanner using Perl for internal
I have been trying to write an image on a layer using Quartz but
I have been doing a lot of searching and still can't seem to figure
I have been trying to write in PHP using a series of regular expressions
I'm using ryan bates' plugin nested_form and i have been trying to write my
I have been trying to write some Java bytecode and assemble it using Jasmin.
I have been trying to write out data to storage when the form closes
I have been trying to write a script where I can post data to
I have been trying to write and read files through P/Invoke via my ASP.NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.