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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:59:13+00:00 2026-06-03T11:59:13+00:00

I’m working on a project where I’m attempting to get a QMesssageBox to exit

  • 0

I’m working on a project where I’m attempting to get a QMesssageBox to exit with the “accepted” condition in response to incoming MIDI data. The MIDI input library (pygame.midi) needs to poll the input to see if any data has arrived, so I start a QThread to handle this, and have it emit a “dataReceived” signal when data arrives in the buffer. I then attach this signal to the QMessageBox’s accept() slot:

def midiLearn(self, mainWindowInstance, widget):


    class midiLearnWait(QtCore.QThread):

        dataReceived = QtCore.pyqtSignal()

        def __init__(self, midiInputDevice, parent=None):
            super(midiLearnWait, self).__init__(parent)
            self.midiInputDevice = midiInputDevice

        def run(self):
            if self.midiInputDevice.poll():
                self.dataReceived.emit()

    if self.midiInputDevice:
        midiLearnMessage = QtGui.QMessageBox(1, 'MIDI Learn', 'Please move a controller.',
                                                         QtGui.QMessageBox.Cancel)
        midiInputThread = midiLearnWait(self.midiInputDevice)
        #just trigger accept for testing
        midiInputThread.dataReceived.connect(lambda: midiLearnMessage.accept())            
        midiInputThread.start()            
        ret = midiLearnMessage.exec_()
        if ret == QtGui.QMessageBox.Cancel:
            return
    else:
        QtGui.QMessageBox.warning(mainWindowInstance, 'MIDI Error', 'No MIDI input selected.')

Unfortunately, this doesn’t seem to work – the message box never gets accepted when MIDI data gets sent to the program. I am not completely sure at this point if the problem is something to do with how I’ve configured the MIDI library, or in how I’ve done this GUI code. If anyone could point out any errors in how I’ve attempted to set up the GUI aspect of the code it would be much appreciated.

  • 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-03T11:59:16+00:00Added an answer on June 3, 2026 at 11:59 am

    midiInputDevice.poll() shouldn’t be a blocking call, so your thread runs once when started and immediately exits… and probably the poll call will return false, that’s why the box stays there.

    you’ll either have to use midiInputDevice.read() (which should block), or poll the device in a loop until there is some data.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I want to show the soap response to UIWebview.. my soap response is, <p><img
I want to construct a data frame in an Rcpp function, but when I
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I need to clean up various Word 'smart' characters in user input, including but
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.