Comments (6)
I found that this problem had been fixed in 'Porting bitmessageqt to Qt5 #1389', but it is not merged to v0.6 .
from pybitmessage.
Truth is a bit different.
The problem that arg() cannot be used is a problem on PyQt version differences, not in Python version differences.
PyQt4's translate() supports arg(), but PyQt5's doesn't.
Example programs follows:
$ cat qt4translate.py
from PyQt4 import QtGui
print(QtGui.QApplication.translate("default", "hello %1").arg("world"))
$ python2 qt4translate.py
hello world
$ cat qt5translate.py
from PyQt5 import QtWidgets
print(QtWidgets.QApplication.translate("default", "hello %1").arg("world"))
$ python2 qt5translate.py
Traceback (most recent call last):
File "qt5translate.py", line 2, in <module>
print(QtWidgets.QApplication.translate("default", "hello %1").arg("world"))
AttributeError: 'unicode' object has no attribute 'arg'
$ cat qtpytranslate.py
from qtpy import QtWidgets
print(QtWidgets.QApplication.translate("default", "hello %1").arg("world"))
$ python2 qtpytranslate.py
Traceback (most recent call last):
File "qtpytranslate.py", line 2, in <module>
print(QtWidgets.QApplication.translate("default", "hello %1").arg("world"))
AttributeError: 'unicode' object has no attribute 'arg'
from pybitmessage.
Simply replacing arg() to format() works well with PyQt5, but it does not work with PyQt4.
$ cat qt5translate-format.py
from PyQt5 import QtWidgets
print(QtWidgets.QApplication.translate("default", "hello {0}").format("world"))
$ python2 qt5translate-format.py
hello world
$ cat qt4translate-format.py
from PyQt4 import QtGui
print(QtGui.QApplication.translate("default", "hello {0}").format("world"))
$ python2 qt4translate-format.py
Traceback (most recent call last):
File "qt4translate-format.py", line 2, in <module>
print(QtGui.QApplication.translate("default", "hello {0}").format("world"))
AttributeError: 'QString' object has no attribute 'format'
So in order to work with both PyQt5 and PyQt4, additional wrapping by str() is required.
$ cat qt5translate-format-str.py
from PyQt5 import QtWidgets
print(str(QtWidgets.QApplication.translate("default", "hello {0}")).format("world"))
$ python2 qt5translate-format-str.py
hello world
$ cat qt4translate-format-str.py
from PyQt4 import QtGui
print(str(QtGui.QApplication.translate("default", "hello {0}")).format("world"))
$ python2 qt4translate-format-str.py
hello world
This also works well with Python3.
$ python3 qt5translate-format-str.py
hello world
$ python3 qt4translate-format-str.py
hello world
The problem is that code becomes complex.
Perhaps it is better to modify the shortcut function _translate() internally apply str().
from pybitmessage.
arg
is needed for the grammar to work correctly. You don't have this issue in Japanese, but you can see it in English, e.g. "1 connection", "2 connections". In other languages it may be even more complex.
from pybitmessage.
I did not noticed it at all!!
Sorry, I don't understand it fully yet, I will investigate it more deeply.
from pybitmessage.
As far as my additional research, QString's arg() is able to be used in only Python2 + PyQt4.
In configurations including Python3 or PyQt5, QString is mapped on Python's native string types (unicode in Python2, str in Python3), and they do not have arg() method.
So if you are going to step forward to Python3 or PyQt5, it is required to drop arg() and use format() instead.
There is no solution that respects compatibility among Python versions nor PyQt versions.
Then, what we should do?
from pybitmessage.
Related Issues (20)
- No chance to run on -> macOS Monterey HOT 2
- Append `*.sql` files into `buildozer.spec`
- APPImage doesn't connect anymore HOT 8
- Bitmesage Plus enhanced security
- Pyelliptic is deprecated HOT 1
- Arch Linux is missing a maintainer
- Linux Mint 21 (cinnamon) incompatibility
- Incorrect stream offset in `HandleDisseminatePreEncryptedMsg`
- *
- Peter Surda (Peter Šurda) poses a significant threat to Bitmessage. HOT 3
- PyQt4 module is not availabale anymore HOT 3
- Newbie on Linux(Ubuntu) with AppImage HOT 1
- Appimage release
- 中文比特channel (ad, can close me)
- How to setup the development environment which is identical to the one core developers are using? HOT 13
- How about using the "Black" code formatter on the whole codebase?
- objectracker.py should be renamed to objecttracker.py
- Texts of the peers are almost invisible on Dark theme of GTK HOT 1
- msgid is stored as text type HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pybitmessage.