-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move to PyQt5 #414
Comments
@Whatang Python3 no longer has support for PyQt4 so they must be done together. I'd say close #413 and update this issue. I've started working on this. It's on a branch. Using the 2to3 script the python2 to python3 went mostly well. I was able to fix all the problems though I'm not confident those fixes are correct. Moving to PyQt5 did not go so well. After fixing the imports for PyQt5 and commenting out some code, I was able to get DrumBurp to open. There are a few things that are horribly broken (like tab editing) and I'm not sure how to go about fixing them. For PyQt5, the biggest pain is probably that setHandlesChildEvents() has been removed. Event handling is different. Slots changed, I'm not sure about the signalling. I am not an expert in python or PyQt5. I do have some experience with Qt5 which is now getting kinda old. Should probably migrate to Qt6 as soon as Qt5 is working. Some of the version numbers are embedded in .ui files, but I don't think I need to run the ui builder to regenerate any files. I just edited version numbers only so they show up in git and can be set properly later. Not surprising, but
Doesn't exist for python3. The lowest version is 1.9.2 and if I try to install it, there is an error about a missing freetype-config. Apparently that was removed from Ubuntu 20.04. No workaround I could see. The last 1.9.x version was 1.9.6 and this didn't install either, so I just installed the latest (without issue). Python versions:
I am on Ubuntu 20.04 and using venv. Here's how I'm developing:
Midi isn't working. When I run DrumBurp as above, I see the following on the terminal:
The
That got rid of alsa warnings, but created a new problem that I fixed. That enabled the midi menu, but play broke it. It seems like the data types arriving at DrumBurp aren't what's expected (float vs int). If I patch that, it fails at
with error:
I think the semantics of pygame.mixer.music.load() have changed. Probably now is a good time to move to mido. |
I was able to fix the midi. I can play and stop and play the score without issue. I had to change StringIO to BytesIO in a couple of places. And then coerce those string values in exportMidi to be bytes. It now looks like this:
And in _playMIDINow, it looks like this:
I had to clean up opening and closing pygame.midi. I took out a bunch of functions related to setting the port because it can't be done with pygame anyway. When Midi playback works now, at least after the alsa symlinks were added. I don't like using pygame for this and I have been playing with pyfluidsynth. I may attempt to integrate that later along with mido for output to any midi port. From what I can tell, export to midi and export to ascii both work. However, there are two serious problems at the moment:
@Whatang, if you know how to fix that one I would appreciate some help. Python is not my language of choice so I'm just hacking. From what I've seen the Drum class implements iter() and getitem() so it should be iterable, but I don't know what the intent of this code is:
There was a third issue which is all the:
Briefly, this was because in QLineLabel.py
And this function in QStaff.py:
Was causing a double add. It doesn't appear that QLineLabel is used anywhere other than QStaff, so it was safe to simply remove the
At the moment, the Section titles (ie. However, the measures themselves can't be edited and opening the drum key editor dialog causes the whole program to crash. And Lilypond export crashes.. |
So it was the presence of this function that threw the unhasable type error.
I commented it out and got different errors to fix. I didn't see it used anywhere. After more changes, the edit drum key opens, and the file dialogs work. One of the issues I found was that the python3 The fix was to find all the I also got lilypond export to work. So the only obvious problem is that the score can't be edited. |
It's awfully quiet in here... I'm still plugging away at this. I don't know why events aren't propagating, but I decided to turn my attention to the unit tests. I don't know how they are supposed to be run, but
Before any includes seems to work well for the files under I ran into a problem that is rather bothersome and I don't know if it affects any other part of the program. The issue is that sets are not ordered. In
When the test runs, the shortcut is not
A simple solution is to just sort the set in this case:
The code would actually need:
so that But the bigger issue is if elsewhere in the code, the sets are expected to be sorted. I don't know so for now I will make that one change to fix that test case. And there is another issue regarding ordered elements. In
And in python2 it looks like:
Whereas in python3 it looks like:
So python2 isn't ordered, but python3 is ordered. To make it work, I have to make the order as per python2.
I have no idea if this is right, but Of course, the next problem is utf8 handling between python2 and python3 in
In other parts of the code, it was easy enough to prepend b to strings (ie. 'my string' becomes b'my string') and that fixed most everything. However, this error is in fileUtils.py. I don't know what's an appropriate way to convert it. As of right now the tests that are failing for me are:
NotePosition is failing because |
The rest of the fixes involve some manner of utf-8 handling. The unit tests now run without errors. And I've pushed the fixes to my branch and it would be great if someone could take a look. @Whatang hasn't been active on github for some time. I hope he's well. @Brayconn I saw you did some excellent work improving Lillypond output. Might I ask you to please have a look at the python3 changes on my branch and point out anything that looks stupid? Fixes for the unit tests did not fix the major problem that the Score can't be edited. I'll continue digging. |
Oh wow, didn't realize anyone was working on this
I can try taking a look, though
With that said...
I'm 99% sure that my contribution actually has an off-by-one error in the code that determines note length. I've encountered many times where the output just breaks when doing weird stuff with quintuplets, septuplets, or even 32nd triplets, and the cause has almost always been that it generated quarters instead of 8ths, or 8ths instead of 16ths, etc. Semi-related: I realized way later that the way the current code generates sticking is almost certainly wrong. The current method causes dense sticking to go way above/below where its supposed be which causes a huge mess on the page. It's been a while since I looked into the solution, but I think it should be using the method shown here under "Drum rolls" (the ^ and _ notation). So yeah, I think the testing for the lilypond code in general needs a lot more work in general. I can provide some scores that cause these issues if needed. |
There was a pull request migrating to python3 that never got integrated and now there's no qt4 available for python3. There's some improvements I'd like to make, namely to the lilypond export, that I can't do on a modern system. So I figured I'd roll up my sleeves and try updating DrumBurp. How hard could it be? ;p
Fair enough. I've used Qt before as qml or c++. Never python. And python being a scripted language adds a lot of difficulty (no compile time checks). It doesn't help that my day job is coding in c and I don't understand the more pythonic ways of writing python code.
I'd appreciate whatever time you can spare. This isn't going very quickly anyway.
That would be good to investigate after DrumBurp is working on python3 and Qt5. The change in meaning for I don't use DrumBurp at the moment for lilypond transcription because the stem directions in the output don't work for me. I should be able to change that in the kit definitions, but there seems to be issues loading and saving kits.
Good to know, I haven't used sticking in any notations yet.
Perhaps once the major issues have been dealt with and a python3/Qt5 release can be built. |
PyQt4 is very old. When moving to Python3 in #413 , also look at converting DB to PyQt5.
The text was updated successfully, but these errors were encountered: