Hi, I have ported qcontrolcenter to python3 and pyqt5.
Even it is working fine, i have some problems with greek names and in help the License.txt and instructions show characters like "b'\t\t" even in English LANG.
source and binary are here
Any help is welcome.
To see what i am talking about install the binary and run it with LANG=el qcontrolcenter and then run it with LANG=en qcontrolcenter
Of course you have to place your desktop files under ~/.qcontrolcenter/ in folders Applications/ Hardware/ Information/ System/
[Solved] qcontrolcenter python3
Re: qcontrolcenter python3
Hi djemos, nice!
You can fix your string issues by adding .decode('UTF-8') to your readLine commands. See this patch:
This is because in python3 you don't read text, even from a text file. You read a "bytes" object, which you have to decode to a string.
You can fix your string issues by adding .decode('UTF-8') to your readLine commands. See this patch:
Code: Select all
--- /usr/bin/helpDialog.py 2022-01-15 22:53:30.000000000 +0200
+++ ./helpDialog.py 2022-01-15 22:59:39.340538465 +0200
@@ -70,7 +70,7 @@
file = QtCore.QFile("/usr/share/qcontrolcenter/INSTRUCTIONS.txt")
if file.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text):
while not file.atEnd():
- textView.append(str(file.readLine().data()))
+ textView.append(str(file.readLine().data().decode('UTF-8')))
textContent = None
vlay.addWidget(textView)
@@ -87,7 +87,7 @@
file = QtCore.QFile("/usr/share/qcontrolcenter/LICENSE.html")
if file.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text):
while not file.atEnd():
- textView.append(str(file.readLine().data()))
+ textView.append(str(file.readLine().data().decode('UTF-8')))
textContent = None
Re: qcontrolcenter python3
Also, all files in your package belong to djemos:users!
Other packages in the slackel repos also have the same problem!
This is caused by an old fakeroot package. Get the one from the salix 15.0 repos.
Other packages in the slackel repos also have the same problem!
This is caused by an old fakeroot package. Get the one from the salix 15.0 repos.
Re: qcontrolcenter python3
Thanks gapan. I will test it.
Re: qcontrolcenter python3
gapan this solves the problen in licence and instructions but folders in Greek do not show in the left or the title in the right.
This code is in the qcontrolcenter file.
This code is in the qcontrolcenter file.
Code: Select all
# This method populates the list of categories in the left hand dock.
def initContentsWidget(self):
folder = QtCore.QDir(CONFIG_DIR)
folder.setFilter(QtCore.QDir.AllDirs)
# Loop inside the categories in the config tree
for folderName in folder.entryInfoList():
# Condider only category names of al laast three characters
if len(folderName.fileName()) > 2:
current_dir = os.path.join( CONFIG_DIR, unicode(folderName.fileName()) )
# Bear in mind that self.contentsWidget is a docked list item
# configButton is an item in that list
configButton = QtWidgets.QListWidgetItem( self.contentsWidget)
configButton.setIcon(QtGui.QIcon( os.path.join(current_dir, FOLDER_ICON) ) )
configButton.setText( self.getSectionTitle(current_dir) )
#configButton.setText(folderName.fileName())
configButton.setTextAlignment( QtCore.Qt.AlignLeft )
# Align center vertically (Didier)
configButton.setTextAlignment( QtCore.Qt.AlignVCenter )
configButton.setData( QtCore.Qt.UserRole, QtCore.QVariant( folderName.fileName()) )
configButton.setFont(QtGui.QFont("DejaVu Sans", 11, QtGui.QFont.Bold))
def getSectionTitle(self, dir_name):
titleList = unicode(dir_name).split("/")
title = titleList[len(titleList)-1]
file_name = os.path.join(dir_name, FOLDER_INI)
if not os.path.exists(file_name):
return title
settings = QtCore.QSettings(file_name, QtCore.QSettings.IniFormat)
if settings.value(LANG).strip() != "":
title = unicode(settings.value(LANG).strip())
#title=LANG
"""
#if len(LANG) > 1
if settings.value(LANG).toString() != "":
title = unicode(settings.value(LANG).toString(), "utf-8")
elif settings.value("default").toString() != "":
title = unicode(settings.value("default").toString(), "utf-8")
"""
return title
Re: qcontrolcenter python3
djemos, I'm not sure what you're talking about. I see greek just fine, both in the left pane and the right one.
Re: qcontrolcenter python3
Problem solved changing these lines
to
Code: Select all
settings = QtCore.QSettings(file_name, QtCore.QSettings.IniFormat)
if settings.value(LANG).toString().trimmed() != "":
title = unicode(settings.value(LANG).toString(), "utf-8")
Code: Select all
settings = QtCore.QSettings(file_name, QtCore.QSettings.IniFormat)
QtCore.QSettings.setIniCodec(settings,"UTF-8") # Sets the codec for accessing INI files (including .conf files on Unix)
if settings.value(LANG) != "":
title = unicode(settings.value(LANG))