I never knew you could just type CMD in the navigation dialog and it would resolve the path within CMD. That was a nonchalant way of learning something amazing. Thanks
hi man thanks for all but i've a question in class class PySide6Ui(): what you writing next? from PySide6.QtWidgets import QApplication, QWidget import subprocess import xml.etree.ElementTree as xml class PySide6Ui():??????????? app QApplication([]) from_class, base_class = PySide6Ui('controle.py').load() win = base_class() form = from_class() form.setupUi(win) win.show() app.show()
I never knew you could just type CMD in the navigation dialog and it would resolve the path within CMD. That was a nonchalant way of learning something amazing. Thanks
Yeah that is such an handy tip :)
thanks bruh!
ty man i really have a big laugh at 9:02 with that trick hahaha
Thanks for sharing:)
Thanks u very much 👏
hi man thanks for all but i've a question in
class
class PySide6Ui():
what you writing next?
from PySide6.QtWidgets import QApplication, QWidget
import subprocess
import xml.etree.ElementTree as xml
class PySide6Ui():???????????
app QApplication([])
from_class, base_class = PySide6Ui('controle.py').load()
win = base_class()
form = from_class()
form.setupUi(win)
win.show()
app.show()
class PySide6Ui:
"""
class to load .ui files to memory or
convert them to .py files
based on:
stackoverflow.com/a/14195313/3781327
usage:
PySide6Ui('myUi.ui').toPy('myUi.py')
PySide6Ui('myUi.ui').toPy()
PySide6Ui('myUi.ui').load()
"""
def __init__(self, ui_file):
self.__ui_file = ui_file
def __getUi(self):
return subprocess.check_output(['pyside6-uic', self.__ui_file])
def toPy(self, py_file=None):
py_file = py_file or self.__ui_file.replace('.ui','.py')
uipy = self.__getUi()
try:
# Write the file
with open(py_file, 'w') as f:
f.write(uipy.decode("utf-8"))
return True
except:
return False
def load(self):
uipy = self.__getUi()
parsed = xml.parse(self.__ui_file)
widget_class = parsed.find('widget').get('class')
form_class = parsed.find('class').text
pyc = compile(uipy, '', 'exec')
frame = {}
exec(pyc, frame)
form_class = frame['Ui_%s'%form_class]# Ui_MainWindow or Ui_Form
base_class = eval('%s'%widget_class)# QMainWindow or QWidget
return form_class, base_class