sharppy / SHARPpy

Sounding/Hodograph Analysis and Research Program in Python
https://sharppy.github.io/SHARPpy/index.html
Other
221 stars 110 forks source link

Using Sharppy Widgets in Seperate PySide Application #77

Closed aarande closed 8 years ago

aarande commented 8 years ago

Hi guys,

I am writing a monitor program in PySide for local use in AWIPS and using the sharptab portion to calculate variables. What I am wondering is it is possible to reuse some of the widgets (i.e. hodo) in sharppy in my application. I have tried to do this by creating a profile collection and instantiating the plotHodo class and adding the widget to my layout but I keep getting a lot of paint errors as shown below. Any ideas on how I might accomplish this?

QPainter::begin: Paint device returned engine == 0, type: 2
QPainter::setRenderHint: Painter must be active to set rendering hints
QPainter::setRenderHint: Painter must be active to set rendering hints
QPainter::setPen: Painter not active
QPainter::drawPath: Painter not active
QPainter::setPen: Painter not active
QPainter::drawPath: Painter not active
QPainter::setPen: Painter not active
QPainter::drawPath: Painter not active
QPainter::setPen: Painter not active
QPainter::drawPath: Painter not active
QPainter::setPen: Painter not active
QPainter::drawPath: Painter not active
QPainter::setPen: Painter not active
QPainter::drawPath: Painter not active
QPainter::setPen: Painter not active
QPainter::drawPath: Painter not active
QPainter::setPen: Painter not active
QPainter::drawPath: Painter not active
QPainter::setPen: Painter not active
QPainter::setPen: Painter not active
QPainter::drawRects: Painter not active
QPainter::drawRects: Painter not active
QPainter::setPen: Painter not active
QPainter::setFont: Painter not active
QPainter::setPen: Painter not active
QPainter::setPen: Painter not active
QPainter::drawRects: Painter not active
QPainter::drawRects: Painter not active
QPainter::setPen: Painter not active
QPainter::setFont: Painter not active
QPainter::setPen: Painter not active
QPainter::drawRects: Painter not active
QPainter::setPen: Painter not active
QPainter::drawRects: Painter not active
QPainter::setPen: Painter not active
QPainter::setFont: Painter not active
QPainter::end: Painter not active, aborted
keltonhalbert commented 8 years ago

IT should be pretty straightforward to stick the hodograph into a separate PySide Application - I'm not sure what the issue with the QPainter is. Let me see if I can dig up an old script where I display only a single window.

aarande commented 8 years ago

Hi Kelton...have you had a chance to look around and see if you had an example of this yet? Thanks!

keltonhalbert commented 8 years ago

Hi @aarande , here's some example code.

It'll yell at you in the terminal output since there's no profile collection/object present, but it gets the idea across.

With Qt, you have to have a QMainWindow - that's where the QPainter comes from, to the best of my knowledge.

import sys
from PySide.QtCore import *
from PySide.QtGui import *
import sharppy.viz as viz

app = QApplication(sys.argv)
mainWindow = QMainWindow()
hodo = viz.plotHodo()
mainWindow.setCentralWidget(hodo)
mainWindow.show()
sys.exit(app.exec_())
aarande commented 8 years ago

Hi Kelton...thanks for the code. This is what I had tried before but was getting errors. I updated my sharppy to the latest master branch and now it is all working. Guess there was something messing up in my older copy (Xenia release).

I know have widgets inside of my other application and it really is awesome! Thanks for all your work on this! I heard someone let you know what I was working on (NSEA Application in AWIPS). Maybe offline I can send you some screenshots and let you know how I am using SHARPpy.

keltonhalbert commented 8 years ago

Hi @aarande ... no problem! Glad it worked!

Yeah, someone from your office was telling me about the work you guys are doing while I was at NWA! I'd love to see some screenshots. Feel free to email me...

keltonhalberr(at)ou.edu