Commit 5a8d77d6 authored by Luke Campagnola's avatar Luke Campagnola
Browse files

Fixed unicode issues with PySide loadUiType

Added unit test for loadUiType
parent 4e555e0b
......@@ -11,6 +11,8 @@ This module exists to smooth out some of the differences between PySide and PyQt
import sys, re
from .python2_3 import asUnicode
## Automatically determine whether to use PyQt or PySide.
## This is done by first checking to see whether one of the libraries
## is already imported. If not, then attempt to import PyQt4, then PySide.
......@@ -56,18 +58,29 @@ if USE_PYSIDE:
# Credit:
class StringIO(object):
"""Alternative to built-in StringIO needed to circumvent unicode/ascii issues"""
def __init__(self): = []
def write(self, data):
def getvalue(self):
return ''.join(map(asUnicode,'utf8')
def loadUiType(uiFile):
Pyside "loadUiType" command like PyQt4 has one, so we have to convert the ui file to py code in-memory first and then execute it in a special frame to retrieve the form_class.
import pysideuic
import xml.etree.ElementTree as xml
from io import StringIO
#from io import StringIO
parsed = xml.parse(uiFile)
widget_class = parsed.find('widget').get('class')
form_class = parsed.find('class').text
with open(uiFile, 'r') as f:
o = StringIO()
frame = {}
import pyqtgraph as pg
import gc
import gc, os
app = pg.mkQApp()
def test_isQObjectAlive():
o1 = pg.QtCore.QObject()
......@@ -8,3 +10,14 @@ def test_isQObjectAlive():
del o1
assert not pg.Qt.isQObjectAlive(o2)
def test_loadUiType():
path = os.path.dirname(__file__)
formClass, baseClass = pg.Qt.loadUiType(os.path.join(path, 'uictest.ui'))
w = baseClass()
ui = formClass()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment