Created
March 27, 2018 21:58
-
-
Save ecarreras/511823096a19bc73ebe88f053c2a8f82 to your computer and use it in GitHub Desktop.
test_show_qt_window.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt4.QtGui import QApplication, QMainWindow, QDialog, QHBoxLayout | |
from PyQt4.QtCore import SIGNAL | |
from Koo.Rpc import Rpc | |
from Koo.Common import Api | |
from Koo.Common import Localization | |
Localization.initializeTranslations() | |
from Koo.Dialogs import WindowService | |
x = Rpc.session.login('http://admin:admin@localhost:8069', 'test_1522167327') | |
app = QApplication([]) | |
class TestWindow(QMainWindow): | |
def addWindow(self, window, target): | |
parent = QApplication.activeModalWidget() | |
if not parent: | |
parent = self | |
dialog = QDialog(parent) | |
dialog.setWindowTitle( _('Wizard') ) | |
dialog.setModal( True ) | |
layout = QHBoxLayout(dialog) | |
layout.setContentsMargins( 0, 0, 0, 0 ) | |
layout.addWidget(window) | |
window.setParent( dialog ) | |
self.connect( window, SIGNAL('closed()'), dialog.accept ) | |
window.show() | |
dialog.exec_() | |
win = TestWindow() | |
class KooApi(Api.KooApi): | |
def execute(self, actionId, data={}, type=None, context={}): | |
Koo.Actions.execute( actionId, data, type, context ) | |
def executeReport(self, name, data={}, context={}): | |
return Koo.Actions.executeReport( name, data, context ) | |
def executeAction(self, action, data={}, context={}): | |
Koo.Actions.executeAction( action, data, context ) | |
def executeKeyword(self, keyword, data={}, context={}): | |
return Koo.Actions.executeKeyword( keyword, data, context ) | |
def createWindow(self, view_ids, model, res_id=False, domain=None, | |
view_type='form', window=None, context=None, mode=None, name=False, autoReload=False, | |
target='current'): | |
WindowService.createWindow( view_ids, model, res_id, domain, | |
view_type, window, context, mode, name, autoReload, target ) | |
def createWebWindow(self, url, title): | |
WindowService.createWebWindow(url, title) | |
def windowCreated(self, window, target): | |
win.addWindow( window, target ) | |
Api.instance = KooApi() | |
Api.instance.createWindow([], 'res.partner', 1, target='current') | |
win.show() | |
Rpc.session.logout() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment