python - Pyside Qpixmap not working -
i new pyside , next tutorial @ http://zetcode.com/gui/pysidetutorial/widgets2/. trying image show in window. seems should able pass in file location image on computer, no matter can't seem display file pass in. help appreciated. thanks!
import sys pyside import qtgui, qtcore class example(qtgui.qwidget): def __init__(self): super(example, self).__init__() self.initui() def initui(self): hbox = qtgui.qhboxlayout(self) pixmap = qtgui.qpixmap("c://users//public//pictures//sample pictures//desert.jpg") lbl = qtgui.qlabel(self) lbl.setpixmap(pixmap) hbox.addwidget(lbl) self.setlayout(hbox) self.setgeometry(300, 300, 280, 170) self.setwindowtitle('red rock') self.show() def main(): app = qtgui.qapplication(sys.argv) ex = example() sys.exit(app.exec_()) if __name__ == '__main__': main()
here's need (related topics: one, two)
create"imageformats"folder in same folder script located (for example, c:\pyprogs\imageformats) copy dlls pyside "imageformats" folder (c:\python27\lib\site-packages\pyside\plugins\imageformats on machine) created folder add code main() function: path = r"c:\pyprogs" app.addlibrarypath(path) full main code:
def main(): app = qtgui.qapplication(sys.argv) path = r"c:\pyprogs" app.addlibrarypath(path) ex = example() sys.exit(app.exec_()) python user-interface python-3.x pyside
No comments:
Post a Comment