Cannot get media to play in wxpython - python

I just want to add a simple video to my application and I cannot get wx.media.MediaCtrl to work.
It seems to fail when I call Load(), I have checked to make sure the path exists ect.
import wx
import wx.media
class TestPanel(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None)
self.testMedia = wx.media.MediaCtrl(self, style=wx.SIMPLE_BORDER, szBackend=wx.media.MEDIABACKEND_QUICKTIME)
self.media = '/Users/nicholasmaisel/Downloads/test.mp4'
self.testMedia.Bind(wx.media.EVT_MEDIA_LOADED, self.play)
self.testMedia.Bind(wx.media.EVT_MEDIA_FINISHED, self.quit)
print(self.testMedia.Load('/Users/nicholasmaisel/Downloads/test.mp4'))
if self.testMedia.Load(self.media):
pass
print("loaded")
else:
self.testMedia.Play()
wx.media.MediaCtrl()
print("Media not found")
self.quit(None)
def play(self, event):
self.testMedia.Play()
def quit(self, event):
self.Destroy()
if __name__ == '__main__':
app = wx.App()
Frame = TestPanel()
Frame.Show()
app.MainLoop()
I just want to add a simple video to a panel in wx.python, if anyone could please help it would be much appreciated.
Thanks

I suggest that you check that you can play the media file with something else before you start. It sounds obvious but it can save ridiculous amounts of wasted time.
Here is your own code, adapted a bit, to allow me to get a screen shot.
Let us know, if it is still giving you grief, after running it, with a valid, tested, video.
import wx
import wx.media
class TestPanel(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title='Media Player')
self.testMedia = wx.media.MediaCtrl(self, style=wx.SIMPLE_BORDER)
self.media = '/home/rolf/27343023_69.mp4'
self.testMedia.Bind(wx.media.EVT_MEDIA_LOADED, self.play)
self.testMedia.Bind(wx.media.EVT_MEDIA_FINISHED, self.quit)
self.Bind(wx.media.EVT_MEDIA_STOP, self.OnMediaStop, self.testMedia)
self.Bind(wx.EVT_CLOSE, self.quit)
if self.testMedia.Load(self.media):
pass
else:
print("Media not found")
self.quit(None)
self.Show()
def play(self, event):
self.testMedia.Play()
def quit(self, event):
self.testMedia.Stop()
self.Destroy()
# Sets the mp4 file in a loop for testing only
def OnMediaStop(self, event):
self.testMedia.Seek(0)
event.Veto()
if __name__ == '__main__':
app = wx.App()
Frame = TestPanel()
app.MainLoop()

Related

check if button clicked or not in pyqt5

Hello guys I want to check if the button clicked or not
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
loadUi("app.ui", self)
self.setWindowIcon(QIcon('discord.png'))
self.setWindowFlag(Qt.WindowMinimizeButtonHint, False)
self.setWindowFlag(Qt.WindowMaximizeButtonHint, False)
self.setFixedSize(self.size())
self.regis = self.findChild(QPushButton, "pushButton")
self.regis.clicked.connect(self.connectt)
self.cl = self.findChild(QPushButton, "pushButton_2")
self.show()
QApplication.processEvents()
def connectt(self):
ID = self.findChild(QLineEdit, "lineEdit")
RP = Presence(ID.text())
RP.connect()
print("connected")
self.statusBar.showMessage('connected')
if self.cl.clicked():
print("disconnected")
app = QApplication(sys.argv)
UIWindow = MainWindow()
app.exec_()
I tried to use self.cl.clicked() but it didn't work!
but I got this error :
if self.cl.clicked():
^^^^^^^^^^^^^^^^^
TypeError: native Qt signal is not callable
can anyone help me, please
You don't need your "if self.cl.clicked():
Assuming "regis" is your button, this line :
self.regis.clicked.connect(self.connectt)
makes it that as soon as you click your "regis" button, the whole "connectt" function will execute.
And if "cl" is another button, your code makes no sense to me, because what your doing is you verify if your "cl" button is clicked when you click your "regis" button (basically clicking two buttons at the same time, which feels strange in my opinion). Maybe you should think about another way to do what you're trying to do.
Let me know if this answered your question.
Edit:
You can use the codeblock like:
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
loadUi("app.ui", self)
self.setWindowIcon(QIcon('discord.png'))
self.setWindowFlag(Qt.WindowMinimizeButtonHint, False)
self.setWindowFlag(Qt.WindowMaximizeButtonHint, False)
self.setFixedSize(self.size())
self.pushButton.clicked.connect(self.pushButtonOperations)
self.pushButton_2.clicked.connect(self.pushButton_2Operations)
self.cl = self.findChild(QPushButton, "pushButton_2")
self.show()
QApplication.processEvents()
def pushButtonOperations(self):
ID = self.findChild(QLineEdit, "lineEdit")
RP = Presence(ID.text())
RP.connect()
print("connected")
self.statusBar.showMessage('connected')
def pushButton_2Operations(self):
print("disconnected")
app = QApplication(sys.argv)
UIWindow = MainWindow()
app.exec_()

wxPython application does not respond

I have a complex application, with a GUI that needs to dialogue with some I/O devices and with some WebAPI. I put my wx.Frame class in the main file, as I read that the GUI should be in the main thread to avoid freezing
if __name__ == "__main__":
app = wx.App()
frame = Window()
app.MainLoop()
but still the GUI freezes very often, and sometimes it doesn't show at all and a message saying "My_app is not responding" appears.
All the I/O and webAPI management is done in separate threads that are created by frame. The only GUI elements that are not in the main file are the pages that compose my notebook
from PageOne import PageOne
from PageTwo import PageTwo
from PageThree import PageThree
...
self.page1 = PageOne(self.nb)
self.page2 = PageTwo(self.nb)
self.page3 = PageThree(self.nb)
self.nb.AddPage(self.page1, "Page1")
self.nb.AddPage(self.page2, "Page2")
self.nb.AddPage(self.page3, "Page3")
All the communications between secondary threads and the GUI are done using wx.lib.newevent.NewEvent() in the main file and wx.PostEvent(self.parent, my_evt) in the threads.
I am using wxpython 4.1.1 and Ubuntu 20.04.2 LTS.
Any suggestion on how to prevent the GUI from not responding or freezing? Is maybe a better idea to use multiprocessing instead of multithreading? I know that threads are usually better for I/O applications...but is it still true in my case where the threads are all enless loops?
def run(self):
while True:
do_stuff()
This is not an answer per se.
However it might help track down a solution.
Given that we have no idea, none, what your code is doing, no one can answer a question like this.
It's the equivalent of asking, How long is a piece of string?
The best advice is to use something like the code below, adapting the thread to perform something akin to what your thread/threads are doing and see if you can replicate the behaviour and hopefully find the cause.
import time
import wx
from threading import Thread
import wx.lib.newevent
progress_event, EVT_PROGRESS_EVENT = wx.lib.newevent.NewEvent()
class ThreadFrame(wx.Frame):
def __init__(self, title, parent=None):
wx.Frame.__init__(self, parent=parent, title=title)
panel = wx.Panel(self)
self.btn = wx.Button(panel,label='Stop Long running process', size=(200,30), pos=(10,10))
self.btn.Bind(wx.EVT_BUTTON, self.OnExit)
self.progress = wx.Gauge(panel,size=(240,10), pos=(10,50), range=240)
#Bind to the progress event issued by the thread
self.Bind(EVT_PROGRESS_EVENT, self.OnProgress)
#Bind to Exit on frame close
self.Bind(wx.EVT_CLOSE, self.OnExit)
self.Show()
self.mythread = TestThread(self)
#Enable the GUI to be responsive by briefly returning control to the main App
while self.mythread.isAlive():
time.sleep(0.1)
wx.GetApp().Yield()
continue
try:
self.OnExit(None)
except:
pass
def OnProgress(self, event):
self.progress.SetValue(event.count)
#or for indeterminate progress
#self.progress.Pulse()
def OnExit(self, event):
if self.mythread.isAlive():
self.mythread.terminate() # Shutdown the thread
self.mythread.join() # Wait for it to finish
self.Destroy()
class TestThread(Thread):
def __init__(self,parent_target):
Thread.__init__(self)
self.parent = parent_target
self.stopthread = False
self.time = time.time()
self.start() # start the thread
def run(self):
# A loop that will run for 2 minutes then terminate
while self.stopthread == False:
curr_loop = int(time.time() - self.time)
if curr_loop < 240:
time.sleep(0.1)
evt = progress_event(count=curr_loop)
#Send back current count for the progress bar
try:
wx.PostEvent(self.parent, evt)
except: # The parent frame has probably been destroyed
self.terminate()
else:
self.terminate()
def terminate(self):
self.stopthread = True
class MyPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.text_count = 0
self.thread_count = 0
self.parent=parent
btn = wx.Button(self, wx.ID_ANY, label='Start Long running process', size=(200,30), pos=(10,10))
btn.Bind(wx.EVT_BUTTON, self.Thread_Frame)
btn2 = wx.Button(self, wx.ID_ANY, label='Is the GUI still active?', size=(200,30), pos=(10,50))
btn2.Bind(wx.EVT_BUTTON, self.AddText)
self.txt = wx.TextCtrl(self, wx.ID_ANY, style= wx.TE_MULTILINE, pos=(10,90),size=(400,100))
def Thread_Frame(self, event):
self.thread_count += 1
frame = ThreadFrame(title='Threaded Task '+str(self.thread_count), parent=self.parent)
def AddText(self,event):
self.text_count += 1
txt = "Gui is still active " + str(self.text_count)+"\n"
self.txt.write(txt)
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title='Main Frame', size=(600,400))
panel = MyPanel(self)
self.Show()
if __name__ == '__main__':
app = wx.App(False)
frame = MainFrame()
app.MainLoop()

wxPython: Show Frame while doing something in other thread

in my GUI with wxPython if have to do some calculations which can take some time. So I want to start them in a seperate Thread and show a window in the GUI that prints that the program is calculating. The main windows should be disabled during this.
So that's my code:
import time
import threading
import wx
def calculate():
# Simulates the calculation
time.sleep(5)
return True
class CalcFrame(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent=None, id=-1, title="Calculate")
# Normally here are some intctrls, but i dont show them to keep it easy
self.panel = wx.Panel(parent=self, id=-1)
self.createButtons()
def createButtons(self):
button = wx.Button(parent=self.panel, id=-1, label="Calculate")
button.Bind(wx.EVT_BUTTON, self.onCalculate)
def onCalculate(self, event):
calcThread = threading.Thread(target=calculate)
checkThread = threading.Thread(target=self.checkThread, args=(calcThread,))
self.createWaitingFrame()
self.waitingFrame.Show(True)
self.Disable()
calcThread.run()
checkThread.run()
def createWaitingFrame(self):
self.waitingFrame = wx.MiniFrame(parent=self, title="Please wait")
panel = wx.Panel(parent=self.waitingFrame)
waitingText = wx.StaticText(parent=panel, label="Please wait - Calculating", style=wx.ALIGN_CENTER)
def checkThread(self, thread):
while thread.is_alive():
pass
print "Fertig"
self.waitingFrame.Destroy()
self.Enable()
app = wx.PySimpleApp()
frame = CalcFrame(parent=None, id=-1)
frame.Show()
app.MainLoop()
But my problem is now, that if i press the "Calculate" button, the waitingFrame isnt't shown right, I can't see the text. I also cant move/maximize/minimize the main window.
Can you help me? Thank you in advance :)
you should never update the gui in a thread other than the main thread .... Im pretty sure the docs for wxPython mention this in several places .. it is not thread safe and your gui gets in broken states ...
instead I believe you are supposed to do something like
def thread1():
time.sleep(5)
return True
def thread2(t1,gui):
while thread.is_alive():
pass
print "Fertig"
wx.CallAfter(gui.ThreadDone)
class MyFrame(wx.Frame):
def startThread(self):
calcThread = threading.Thread(target=thread1)
checkThread = threading.Thread(target=thread2, args=(calcThread,self))
def ThreadDone(self):
print "Both threads done???"
print "Now modify gui from main thread(here!)"

How can I develop Windows PC background tray apps using Python? [duplicate]

I'd just need a quick example on how to easily put an icon with python on my systray. This means: I run the program, no window shows up, just a tray icon (I've got a png file) shows up in the systray and when I right-click on it a menu appears with some options (and when I click on an option, a function is run).
Is that possible? I don't need any window at all...
Examples / code snippets are REALLY appreciated! :D
For Windows & Gnome
Here ya go! wxPython is the bomb. Adapted from the source of my Feed Notifier application.
import wx
TRAY_TOOLTIP = 'System Tray Demo'
TRAY_ICON = 'icon.png'
def create_menu_item(menu, label, func):
item = wx.MenuItem(menu, -1, label)
menu.Bind(wx.EVT_MENU, func, id=item.GetId())
menu.AppendItem(item)
return item
class TaskBarIcon(wx.TaskBarIcon):
def __init__(self):
super(TaskBarIcon, self).__init__()
self.set_icon(TRAY_ICON)
self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.on_left_down)
def CreatePopupMenu(self):
menu = wx.Menu()
create_menu_item(menu, 'Say Hello', self.on_hello)
menu.AppendSeparator()
create_menu_item(menu, 'Exit', self.on_exit)
return menu
def set_icon(self, path):
icon = wx.IconFromBitmap(wx.Bitmap(path))
self.SetIcon(icon, TRAY_TOOLTIP)
def on_left_down(self, event):
print 'Tray icon was left-clicked.'
def on_hello(self, event):
print 'Hello, world!'
def on_exit(self, event):
wx.CallAfter(self.Destroy)
def main():
app = wx.PySimpleApp()
TaskBarIcon()
app.MainLoop()
if __name__ == '__main__':
main()
2018 version
import wx.adv
import wx
TRAY_TOOLTIP = 'Name'
TRAY_ICON = 'icon.png'
def create_menu_item(menu, label, func):
item = wx.MenuItem(menu, -1, label)
menu.Bind(wx.EVT_MENU, func, id=item.GetId())
menu.Append(item)
return item
class TaskBarIcon(wx.adv.TaskBarIcon):
def __init__(self, frame):
self.frame = frame
super(TaskBarIcon, self).__init__()
self.set_icon(TRAY_ICON)
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN, self.on_left_down)
def CreatePopupMenu(self):
menu = wx.Menu()
create_menu_item(menu, 'Site', self.on_hello)
menu.AppendSeparator()
create_menu_item(menu, 'Exit', self.on_exit)
return menu
def set_icon(self, path):
icon = wx.Icon(path)
self.SetIcon(icon, TRAY_TOOLTIP)
def on_left_down(self, event):
print ('Tray icon was left-clicked.')
def on_hello(self, event):
print ('Hello, world!')
def on_exit(self, event):
wx.CallAfter(self.Destroy)
self.frame.Close()
class App(wx.App):
def OnInit(self):
frame=wx.Frame(None)
self.SetTopWindow(frame)
TaskBarIcon(frame)
return True
def main():
app = App(False)
app.MainLoop()
if __name__ == '__main__':
main()
wx.PySimpleApp deprecated, here's how to use wx.App instead
Took me while to figure this out so I thought I'd share. wx.PySimpleApp is deprecated in wxPython 2.9 and beyond. Here's FogleBird's original script using wx.App instead.
import wx
TRAY_TOOLTIP = 'System Tray Demo'
TRAY_ICON = 'icon.png'
def create_menu_item(menu, label, func):
item = wx.MenuItem(menu, -1, label)
menu.Bind(wx.EVT_MENU, func, id=item.GetId())
menu.AppendItem(item)
return item
class TaskBarIcon(wx.TaskBarIcon):
def __init__(self, frame):
self.frame = frame
super(TaskBarIcon, self).__init__()
self.set_icon(TRAY_ICON)
self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.on_left_down)
def CreatePopupMenu(self):
menu = wx.Menu()
create_menu_item(menu, 'Say Hello', self.on_hello)
menu.AppendSeparator()
create_menu_item(menu, 'Exit', self.on_exit)
return menu
def set_icon(self, path):
icon = wx.IconFromBitmap(wx.Bitmap(path))
self.SetIcon(icon, TRAY_TOOLTIP)
def on_left_down(self, event):
print 'Tray icon was left-clicked.'
def on_hello(self, event):
print 'Hello, world!'
def on_exit(self, event):
wx.CallAfter(self.Destroy)
self.frame.Close()
class App(wx.App):
def OnInit(self):
frame=wx.Frame(None)
self.SetTopWindow(frame)
TaskBarIcon(frame)
return True
def main():
app = App(False)
app.MainLoop()
if __name__ == '__main__':
main()
If you can guarantee windows and you do not want to introduce the heavy dependencies of wx, you can do this with the pywin32 extensions.
Also see this question.
For Ubuntu
class TrayIcon:
def init():
iconPath = {"Windows":os.path.expandvars("%PROGRAMFILES%/MyProgram/icon.png"),
"Linux":"/usr/share/icons/myprogramicon.png"}
if platform.system()=="Linux":
import gtk
import appindicator # Ubuntu apt-get install python-appindicator
# Create an application indicator
try:
gtk.gdk.threads_init()
gtk.threads_enter()
icon = iconPath[platform.system()]
indicator = appindicator.Indicator("example-simple-client", "indicator-messages", appindicator.CATEGORY_APPLICATION_STATUS)
indicator.set_icon(icon)
indicator.set_status (appindicator.STATUS_ACTIVE)
indicator.set_attention_icon ("indicator-messages-new")
menu = gtk.Menu()
menuTitle = "Quit"
menu_items = gtk.MenuItem(menuTitle)
menu.append(menu_items)
menu_items.connect("activate", TrayIcon.QuitApp, menuTitle)
menu_items.show()
menuTitle = "About My Program"
menu_items = gtk.MenuItem(menuTitle)
menu.append(menu_items)
menu_items.connect("activate", TrayIcon.AboutApp, menuTitle)
menu_items.show()
indicator.set_menu(menu)
except:
pass
# Run the app indicator on the main thread.
try:
t = threading.Thread(target=gtk.main)
t.daemon = True # this means it'll die when the program dies.
t.start()
#gtk.main()
except:
pass
finally:
gtk.threads_leave()
#staticmethod
def AboutApp(a1,a2):
gtk.threads_enter()
dialog = gtk.Dialog("About",
None,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
label = gtk.Label("My Program v0.0.1, (C)opyright ME 2015. All rights reserved.")
dialog.vbox.pack_start(label)
label.show()
label2 = gtk.Label("example.com\n\nFor more support contact me#gmail.com")
label2.show()
dialog.action_area.pack_end(label2)
response = dialog.run()
dialog.destroy()
gtk.threads_leave()
#staticmethod
def QuitApp(a1, a2):
sys.exit(0)
Cross-Platform
See PyQt: Show menu in a system tray application
There is a package called pystray (bad name, just say it out loud) but works like a charm and is more lightweight than wx or Qt. These are the links:
https://pystray.readthedocs.io/en/latest/index.html
https://pypi.org/project/pystray/
Yes. There is a cross-platform example on wiki.wxpython.org that I've tested with python 2.7 (minconda install) on macOS High Sierra (10.13.3), Windows 7, and gnome 3/centos7. It is here (ignore the page title):
https://wiki.wxpython.org/Custom%20Mac%20OsX%20Dock%20Bar%20Icon
Small mods are needed for python 3.6:
you must import wx.adv
wx.TaskBarIcon becomes wx.adv.TaskBarIcon
wx.IconFromBitmap becomes wx.Icon
Gnome 3 required installation of TopIcons Plus.
Since you don't want to have the window display (" no window shows up, just a tray icon"), simply comment out the following line (though you still want to keep the wx.Frame parent):
frame.Show(True)
And since you want to use your own .png icon, remove the WXPdemo image and embeddedimage stuff and replace
icon = self.MakeIcon(WXPdemo.GetImage())
with, for example
icon = wx.Icon('icon.png')
In my experience, this will provide a good start for adapting or extending further.
An alternative if you are trying to run a python based program in the background you can run it as a service. Check out this active state recipe its pretty useful. I believe one of the options is to convert your application to exe with py2exe or pyinstall.
http://code.activestate.com/recipes/551780/
For an example, refer to this thread -> wx question.
wxPython "classic" -> [new API] wxPython 'Phoenix' (Py3)

dropEvent() not getting called

I am trying to perform a drag and drop operation from a QTreeWidget to QGraphicsView. dragStart() works, and dragEnterEvent() works, but dropEvent() is never being called. Also the pixmap is not showing up until the cursor enters the QGraphicsView, which isn't a problem, but I just thought it would appear as soon as the drag started. Here is my startDrag function:
def on_list_startDrag(self, supportedActions):
#Retreive the item that was clicked on
currentPart = self.ui.list.currentItem()
part = currentPart.text(0)
drag = QtGui.QDrag(self.ui.list)
mime = QtCore.QMimeData()
print(part)
#retreive that associated graphics file
icon = QtGui.QIcon('drawings/FULL/' + part + '.svg')
pixmap = icon.pixmap(102,122)
selected = QtGui.QImage('drawings/FULL/' + part + '.svg')
data = pickle.dumps(selected)
mime.setData('application/x-item', data)
#mime.setImageData(QtGui.QImage('drawings/FULL/' + part + '.svg'))
drag.setMimeData(mime)
drag.setHotSpot(QtCore.QPoint(pixmap.width()/2, pixmap.height()/2))
drag.setPixmap(pixmap)
drag.exec_()
Here is the the dragEnterEvent:
def on_workArea_dragEnterEvent(self, event):
print(event.format())
if (event.mimeData().hasFormat('application/x-item')):
event.accept()
print('accepted')
else:
event.ignore()
Finally the dropEvent code:
def on_workArea_dropEvent(self, event):
print('dropped')
When I start the drag and drop operation is happening the cursor has the circle with the slash like the widget doesn't accept drops, but I set the QGraphicsView, workArea, to accept drops. Can someone please help me get the drop working and explain why the pixmap doesn't show up behind the cursor until the cursor is over the QGraphicsView. Thank you.
You need to implement dragMoveEvent() as well, or dropEvent() won't be called. This is also what causes it to show a proper drop icon, instead of the slashed-circle "can't drop here" icon.
I've checked your code and it does look and work fine for me; both dropEvent and pixmap work as expected. Perhaps there's smth else in your code which causes this unwanted behaviour you're describing. As for the dropEvent, you might have problems connecting slot to a signal, which leads to your code not being called. I've made a small example which does drag and drop between treeview and grahicsview and loads and presents a pixmap:
import sys
from PyQt4 import QtGui, QtCore
class TestTreeView(QtGui.QTreeView):
def __init__(self, parent = None):
super(TestTreeView, self).__init__(parent)
self.setDragEnabled(True)
def startDrag(self, dropAction):
print('tree start drag')
icon = QtGui.QIcon('/home/image.png')
pixmap = icon.pixmap(64, 64)
mime = QtCore.QMimeData()
mime.setData('application/x-item', '???')
drag = QtGui.QDrag(self)
drag.setMimeData(mime)
drag.setHotSpot(QtCore.QPoint(pixmap.width()/2, pixmap.height()/2))
drag.setPixmap(pixmap)
drag.start(QtCore.Qt.CopyAction)
class TestGraphicsView(QtGui.QGraphicsView):
def __init__(self, parent = None):
super(TestGraphicsView, self).__init__(parent)
self.setAcceptDrops(True)
def dragEnterEvent(self, event):
print('graphics view drag enter')
if (event.mimeData().hasFormat('application/x-item')):
event.acceptProposedAction()
print('accepted')
else:
event.ignore()
def dropEvent(self, event):
print('graphics view drop')
event.acceptProposedAction()
class MainForm(QtGui.QMainWindow):
def __init__(self, parent=None):
super(MainForm, self).__init__(parent)
self.model = QtGui.QStandardItemModel()
for k in range(0, 4):
parentItem = self.model.invisibleRootItem()
for i in range(0, 4):
item = QtGui.QStandardItem(QtCore.QString("item %0 %1").arg(k).arg(i))
parentItem.appendRow(item)
parentItem = item
self.setMinimumSize(300, 400)
self.view = TestTreeView(self)
self.view.setModel(self.model)
self.view.setMinimumSize(300, 200)
self.graphicsView = TestGraphicsView(self)
self.graphicsView.setGeometry(0, 210, 300, 400)
self.layout = QtGui.QVBoxLayout(self.centralWidget())
self.layout.addWidget(self.view)
self.layout.addWidget(self.graphicsView)
def main():
app = QtGui.QApplication(sys.argv)
form = MainForm()
form.show()
app.exec_()
if __name__ == '__main__':
main()
hope this helps, regards

Categories