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 6913459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:13:19+00:00 2026-05-27T09:13:19+00:00

Consider the minimal example below. It works perfectly until I uncomment the following lines:

  • 0

Consider the minimal example below. It works perfectly until I uncomment the following lines:

# self.mainwi = QtGui.QWidget(self)
# self.lineEdit1 = QtGui.QLineEdit(self.mainwi)
# self.setCentralWidget(self.lineEdit1)

If those lines are uncommented, I can write text in the LineEdit-field, but the buttons don’t react. Any idea what’s wrong with it, how to fix this?

I should add that I am an absolute beginner in programming python.

#!/usr/bin/python

import mpylayer
import sys
from PyQt4 import QtCore
from PyQt4 import QtGui



class DmplayerGUI(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.dirty = False
        self.mp = mpylayer.MPlayerControl()
        #Toolbar
        ## items

        ### Play
        self.play = QtGui.QAction(QtGui.QIcon('icons/play_32.png'), 'Play', self)
        self.play.setShortcut('Ctrl+A')
        self.connect(self.play, QtCore.SIGNAL('triggered()'), self.DPlay)

        ### Pause
        self.pause = QtGui.QAction(QtGui.QIcon('icons/pause_32.png'), 'Pause', self)
        self.pause.setShortcut('Ctrl+P')
        self.connect(self.pause, QtCore.SIGNAL('triggered()'), self.DPause)


        ## toolbar
        self.toolbar = self.addToolBar('Toolbar')
        self.toolbar.addAction(self.play)
        self.toolbar.addAction(self.pause)

        # self.mainwi = QtGui.QWidget(self)
        # self.lineEdit1 = QtGui.QLineEdit(self.mainwi)
        # self.setCentralWidget(self.lineEdit1)

    # play
    def DPlay(self):
        self.mp.loadfile('video.mp4')

    # pause
    def DPause(self):
        self.mp.pause(self)


if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    dp = DmplayerGUI()
    dp.show()
    sys.exit(app.exec_())
  • 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-05-27T09:13:19+00:00Added an answer on May 27, 2026 at 9:13 am

    You do not need the mainwi at all in this simple example. Just do

    self.lineEdit1 = QtGui.QLineEdit(self)
    self.setCentralWidget(self.lineEdit1)
    

    In case you really wanted it, then you need to set the mainwi as the centralwidget

    self.mainwi = QtGui.QWidget(self)
    self.lineEdit1 = QtGui.QLineEdit(self.mainwi)
    self.setCentralWidget(self.mainwi)
    

    do not forget to add some layout for mainwi, since this looks ugly 🙂

    Anyway, I have to admit, that I do not know why exactly does it “disable” the buttons. But the central widget has to be a child of the window as far as I know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following minimal example: #include <iostream> using namespace std; class myostream : public
Consider the following setup: A windows PC with a LAN interface and a WiFi
Consider the following ruby code test.rb: begin puts thisFunctionDoesNotExist x = 1+1 rescue Exception
Consider the following 2 queries: select tblA.a,tblA.b,tblA.c,tblA.d from tblA where tblA.a not in (select
In C, function declarations can be prototype or non-prototype declarations. For example, consider the
I have several lists, that you can consider as rows of integers. For example
Consider the following code: // MyClass.h @interface MyClass @property NSInteger Value; @end //MyClass.m @implementation
Consider the SQL query below: SELECT * FROM opening_hours WHERE week_day = WEEKDAY(NOW()) +
Consider the following set up: - SomeFilter extends Filter - Filter implements Runnable -
Consider the following code: Class Demo { Person person = new Person(foo); // assume

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.