Bugzilla – Attachment 157320 Details for
Bug 124562
IDE: Dialogs: Simulating tabbed dialog boxes using Page/Step property is not documented
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Tabbed UI dialog example using Python
tabs.py (text/plain), 3.67 KB, created by
LibreOļ¬ciant
on 2020-01-22 12:47:03 UTC
(
hide
)
Description:
Tabbed UI dialog example using Python
Filename:
MIME Type:
Creator:
LibreOļ¬ciant
Created:
2020-01-22 12:47:03 UTC
Size:
3.67 KB
patch
obsolete
># -*- coding: utf-8 -*- >from __future__ import unicode_literals > >""" > Adapted from "How to get Active Tab/Page ID from a python dialog box?" > https://ask.libreoffice.org/en/question/174189/how-to-get-active-tabpage-id-from-a-python-dialog-box/ >""" > >import uno, unohelper >from com.sun.star.awt.PosSize import POS, SIZE, POSSIZE >from com.sun.star.awt.PushButtonType import CANCEL, STANDARD > >def tabbedDialog(): > WIDTH = 400 > HORI_MARGIN = VERT_MARGIN = 8 > BUTTON_WIDTH = 100 > BUTTON_HEIGHT = 26 > HORI_SEP = VERT_SEP = 8 > LABEL_HEIGHT = BUTTON_HEIGHT * 2 + 5 > EDIT_HEIGHT = 500 > HEIGHT = VERT_MARGIN * 2 + LABEL_HEIGHT + VERT_SEP + EDIT_HEIGHT > OFFSET = 25 > > ctx = uno.getComponentContext() > def create(name): > return ctx.getServiceManager().createInstanceWithContext(name, ctx) > > # Setup Dialog window > dialog = create("com.sun.star.awt.UnoControlDialog") > dialogModel = create("com.sun.star.awt.UnoControlDialogModel") > dialog.setModel(dialogModel) > dialog.setVisible(False) > dialog.setTitle("Dialog Title") > dialog.setPosSize(0, 0, WIDTH, HEIGHT, SIZE) > > # Add an element to a parent model and return the model for the new element > def add(name, type, parentModel, x_, y_, width_, height_, props): > model = parentModel.createInstance("com.sun.star.awt." + type) > parentModel.insertByName(name, model) > control = dialog.getControl(name) > if width_ > 0 and height_ > 0: > control.setPosSize(x_, y_, width_, height_, POSSIZE) > for key, value in props.items(): > setattr(model, key, value) > return model > > # Set up Dialog Box > add("btn_cancel", "UnoControlButtonModel", dialogModel, > (WIDTH/2), (HEIGHT) - (BUTTON_HEIGHT + OFFSET), > BUTTON_WIDTH, BUTTON_HEIGHT, > {"PushButtonType": CANCEL, "DefaultButton": True}) > > add("btn_action", "UnoControlButtonModel", dialogModel, > (WIDTH/2) - (BUTTON_WIDTH), (HEIGHT) - (BUTTON_HEIGHT + OFFSET), > BUTTON_WIDTH, BUTTON_HEIGHT, > {"PushButtonType": STANDARD, "Label": "Page Action"}) > > # Do stuff with info on the current tab > oControl = dialog.getControl("btn_action") > oControl.addActionListener(ActionListener(dialog)) > > tabContainer = add("tabController", "UnoMultiPageModel", dialogModel, > HORI_MARGIN, VERT_MARGIN, > WIDTH - (HORI_MARGIN*2), HEIGHT - OFFSET - (BUTTON_HEIGHT*2), > {"Enabled": True, "EnableVisible": True}) > > pgNames = ["Page_1", "Page_2", "Page_3"] > for idx, name in enumerate(pgNames): > pgModel = add(pgNames[idx], "UnoPageModel", tabContainer, > 0, 0, 0, 0, > {"Title": name, "EnableVisible": True}) > # How to use XSimpleTabController interface functions to get Tab Info needed > > frame = create("com.sun.star.frame.Desktop").getCurrentFrame() > window = frame.getContainerWindow() if frame else None > dialog.createPeer(create("com.sun.star.awt.Toolkit"), window) > pos = window.getPosSize() > _x = pos.Width / 2 - WIDTH / 2 > _y = pos.Height / 2 - HEIGHT / 2 > dialog.setPosSize(_x, _y, 0, 0, POS) > if dialog.execute() == 0: > print("Cancel Pressed") > oControl = dialog.getControl("btn_action") > oControl.removeActionListener(ActionListener(dialog)) > dialog.dispose() > return > >from com.sun.star.awt import XActionListener >class ActionListener(unohelper.Base, XActionListener): > def __init__(self, dialog): > self.my_dialog = dialog > def disposing(self, ev): > pass > def actionPerformed(self, ev): > oControl = self.my_dialog.getControl("tabController") > active_tab = oControl.getActiveTabID()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 124562
: 157320