Exemplo n.º 1
0
def vtkKWMessageDialogEntryPoint(parent, win):

    app = parent.GetApplication()

    # -----------------------------------------------------------------------

    # Create a message box

    msg_dlg1 = vtkKWMessageDialog()
    msg_dlg1.SetParent(parent)
    msg_dlg1.SetMasterWindow(win)
    msg_dlg1.SetStyleToOkCancel()
    msg_dlg1.Create()
    msg_dlg1.SetTitle("Your attention please!")
    msg_dlg1.SetText(
        "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc felis. "
        "Nulla gravida. Aliquam erat volutpat. Mauris accumsan quam non sem. "
        "Sed commodo, magna quis bibendum lacinia, elit turpis iaculis augue, "
        "eget hendrerit elit dui vel elit.")

    # -----------------------------------------------------------------------

    # Create a push button to invoke the message box

    msg_dlg_button1 = vtkKWPushButton()
    msg_dlg_button1.SetParent(parent)
    msg_dlg_button1.Create()
    msg_dlg_button1.SetText("Press to invoke message box")
    msg_dlg_button1.SetCommand(msg_dlg1, "Invoke")

    app.Script("pack %s -side top -anchor nw -expand n -padx 2 -pady 2",
               msg_dlg_button1.GetWidgetName())

    return "TypeComposite"
Exemplo n.º 2
0
def vtkKWMessageDialogEntryPoint(parent, win):

    app = parent.GetApplication()
    
    # -----------------------------------------------------------------------
    
    # Create a message box
    
    msg_dlg1 = vtkKWMessageDialog()
    msg_dlg1.SetParent(parent)
    msg_dlg1.SetMasterWindow(win)
    msg_dlg1.SetStyleToOkCancel()
    msg_dlg1.Create()
    msg_dlg1.SetTitle("Your attention please!")
    msg_dlg1.SetText(
        "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc felis. "
        "Nulla gravida. Aliquam erat volutpat. Mauris accumsan quam non sem. "
        "Sed commodo, magna quis bibendum lacinia, elit turpis iaculis augue, "
        "eget hendrerit elit dui vel elit.")
    
    # -----------------------------------------------------------------------
    
    # Create a push button to invoke the message box
    
    msg_dlg_button1 = vtkKWPushButton()
    msg_dlg_button1.SetParent(parent)
    msg_dlg_button1.Create()
    msg_dlg_button1.SetText("Press to invoke message box")
    msg_dlg_button1.SetCommand(msg_dlg1, "Invoke")
    
    app.Script(
        "pack %s -side top -anchor nw -expand n -padx 2 -pady 2",
        msg_dlg_button1.GetWidgetName())
    
    
    
    return "TypeComposite"
Exemplo n.º 3
0
def vtkKWTreeEntryPoint(parent, win):

    app = parent.GetApplication()
    
    # -----------------------------------------------------------------------
    
    # Create a tree
    
    tree1 = vtkKWTreeWithScrollbars()
    tree1.SetParent(parent)
    tree1.Create()
    tree1.SetBalloonHelpString("A simple tree")
    tree1.SetBorderWidth(2)
    tree1.SetReliefToGroove()
    tree1.ResizeButtonsVisibilityOn()

    tree = tree1.GetWidget()
    tree.SelectionFillOn()
    tree.EnableReparentingOn()
    
    # Inbox node. Use a predefined icon as image, make room for it (pad)

    tree.AddNode(None, "inbox_node", "Inbox")
    tree.SetNodeImageToPredefinedIcon("inbox_node", 1903)
    tree.SetNodePadX("inbox_node", 18)
    
    # Outbox node. Use a predefined icon as image, make room for it (pad)

    tree.AddNode(None, "outbox_node", "Outbox")
    tree.SetNodeImageToPredefinedIcon("outbox_node", 1904)
    tree.SetNodePadX("outbox_node", 18)
    
    # Trash node. Create a pushbutton and use it as an extra widget to the
    # left of the node text. Make room for it (pad), make sure it blends
    # with the tree by matching the background color. Use a predefined icon
    # for the pushbutton image, and set a simple callback that will change
    # the image to a different icon (just to examplify).

    tree.AddNode(None, "trash_node", "Trash")
    empty_trash_button = vtkKWPushButton()
    empty_trash_button.SetParent(tree)
    empty_trash_button.Create()
    empty_trash_button.SetBorderWidth(0)
    empty_trash_button.SetBackgroundColor(tree.GetBackgroundColor())
    empty_trash_button.SetActiveBackgroundColor(tree.GetBackgroundColor())
    empty_trash_button.SetImageToPredefinedIcon(1902)
    empty_trash_button.SetCommand(
        empty_trash_button, "SetImageToPredefinedIcon 1901")
    tree.SetNodeWindow("trash_node", empty_trash_button)
    tree.SetNodePadX("trash_node", 18)
    
    # Company nodes

    tree.AddNode(None, "kitware_node", "Kitware")
    tree.SetNodeFontWeightToBold("kitware_node")
    tree.SetNodeSelectableFlag("kitware_node", 0)
    tree.OpenTree("kitware_node")
    
    tree.AddNode("kitware_node", "berk_node", "Berk Geveci")
    
    tree.AddNode("kitware_node", "seb_node", "Sebastien Barre")
    
    tree.AddNode("kitware_node", "ken_node", "Ken Martin")
    
    app.Script(
        "pack %s -side top -anchor nw -expand n -padx 2 -pady 2",
        tree1.GetWidgetName())
    
    
    
    return "TypeCore"
Exemplo n.º 4
0
def vtkKWPushButtonEntryPoint(parent, win):

    app = parent.GetApplication()
    
    # -----------------------------------------------------------------------
    
    # Create a push button
    
    pushbutton1 = vtkKWPushButton()
    pushbutton1.SetParent(parent)
    pushbutton1.Create()
    pushbutton1.SetText("A push button")
    
    app.Script(
        "pack %s -side top -anchor nw -expand n -padx 2 -pady 2",
        pushbutton1.GetWidgetName())
    
    # -----------------------------------------------------------------------
    
    # Create another push button, use an icon
    
    pushbutton2 = vtkKWPushButton()
    pushbutton2.SetParent(parent)
    pushbutton2.Create()
    pushbutton2.SetImageToPredefinedIcon(vtkKWIcon.IconConnection)
    pushbutton2.SetBalloonHelpString(
        "Another pushbutton, using one of the predefined icons")
    
    app.Script(
        "pack %s -side top -anchor nw -expand n -padx 2 -pady 6",
        pushbutton2.GetWidgetName())
    
    # -----------------------------------------------------------------------
    
    # Create another push button, use both text and icon
    
    pushbutton2b = vtkKWPushButton()
    pushbutton2b.SetParent(parent)
    pushbutton2b.Create()
    pushbutton2b.SetText("A push button with an icon")
    pushbutton2b.SetImageToPredefinedIcon(vtkKWIcon.IconWarningMini)
    pushbutton2b.SetCompoundModeToLeft()
    pushbutton2b.SetBalloonHelpString(
        "Another pushbutton, using both a text and one of the predefined icons")
    
    app.Script(
        "pack %s -side top -anchor nw -expand n -padx 2 -pady 6",
        pushbutton2b.GetWidgetName())
    
    # -----------------------------------------------------------------------
    
    # Create another push button, with a label this time
    
    pushbutton3 = vtkKWPushButtonWithLabel()
    pushbutton3.SetParent(parent)
    pushbutton3.Create()
    pushbutton3.SetLabelText("Press this...")
    pushbutton3.GetWidget().SetText("button")
    pushbutton3.SetBalloonHelpString(
        "This is a vtkKWPushButtonWithLabel, i.e. a pushbutton associated to a "
        "label that can be positioned around the pushbutton.")
    
    app.Script(
        "pack %s -side top -anchor nw -expand n -padx 2 -pady 6",
        pushbutton3.GetWidgetName())
    
    # -----------------------------------------------------------------------

    # Create another push button, with a menu

    pushbutton4 = vtkKWPushButtonWithMenu()
    pushbutton4.SetParent(parent)
    pushbutton4.Create()
    pushbutton4.GetPushButton().SetImageToPredefinedIcon(
        vtkKWIcon.IconTransportRewind)
    pushbutton4.SetBalloonHelpString(
        "This is a vtkKWPushButtonWithMenu, i.e. a pushbutton associated to a "
        "menu.")
    
    menu = pushbutton4.GetMenu()
    menu.AddCommand("Microsoft Office")
    menu.AddCommand("Program Files")
    menu.AddCommand("C:")
    
    app.Script(
        "pack %s -side top -anchor nw -expand n -padx 2 -pady 6", 
        pushbutton4.GetWidgetName())

    # -----------------------------------------------------------------------
    
    # Create a set of pushbutton
    # An easy way to create a bunch of related widgets without allocating
    # them one by one
    
    pushbutton_set = vtkKWPushButtonSet()
    pushbutton_set.SetParent(parent)
    pushbutton_set.Create()
    pushbutton_set.SetBorderWidth(2)
    pushbutton_set.SetReliefToGroove()
    pushbutton_set.SetWidgetsPadX(1)
    pushbutton_set.SetWidgetsPadY(1)
    pushbutton_set.SetPadX(1)
    pushbutton_set.SetPadY(1)
    pushbutton_set.ExpandWidgetsOn()
    pushbutton_set.SetMaximumNumberOfWidgetsInPackingDirection(3)
    
    for id in range(0,9):
        buffer = "Push button %d" % (id)
        pushbutton = pushbutton_set.AddWidget(id)
        pushbutton.SetText(buffer)
        pushbutton.SetBackgroundColor(
            vtkMath.HSVToRGB(float(id) / 8.0, 0.3, 0.75))
        pushbutton.SetBalloonHelpString(
            "This pushbutton is part of a unique set (a vtkKWPushButtonSet), "
            "which provides an easy way to create a bunch of related widgets "
            "without allocating them one by one. The widgets can be layout as a "
            "NxM grid. Each button is assigned a different color.")
        
    
    pushbutton_set.GetWidget(0).SetText("I'm the first button")
    
    app.Script(
        "pack %s -side top -anchor nw -expand n -padx 2 -pady 6",
        pushbutton_set.GetWidgetName())
    
    
    # TODO: add callbacks
    
    
    return "TypeCore"
Exemplo n.º 5
0
def vtkKWNotebookEntryPoint(parent, win):

    app = parent.GetApplication()
    
    # -----------------------------------------------------------------------
    
    # Create a notebook
    
    notebook1 = vtkKWNotebook()
    notebook1.SetParent(parent)
    notebook1.SetMinimumWidth(400)
    notebook1.SetMinimumHeight(200)
    notebook1.Create()
    
    app.Script(
        "pack %s -side top -anchor nw -expand n -padx 2 -pady 2",
        notebook1.GetWidgetName())
    
    # Add some pages
    
    notebook1.AddPage("Page 1")
    
    notebook1.AddPage("Page Blue")
    notebook1.GetFrame("Page Blue").SetBackgroundColor(0.2, 0.2, 0.9)
    
    page_id = notebook1.AddPage("Page Red")
    notebook1.GetFrame(page_id).SetBackgroundColor(0.9, 0.2, 0.2)
    
    # -----------------------------------------------------------------------

    # Create a notebook inside one of the page (because we can)

    page_id = notebook1.AddPage("Sub Notebook")

    notebook2 = vtkKWNotebook()
    notebook2.SetParent(notebook1.GetFrame(page_id))
    notebook2.Create()
    notebook2.EnablePageTabContextMenuOn()
    notebook2.PagesCanBePinnedOn()
    notebook2.UseFrameWithScrollbarsOn()
    
    # -----------------------------------------------------------------------
    
    # Create a message inside one of the page (as a test for scrollbars)

    page_id = notebook2.AddPage("Page A")

    lorem_ipsum = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc felis. Nulla gravida. Aliquam erat volutpat. Mauris accumsan quam non sem. Sed commodo, magna quis bibendum lacinia, elit turpis iaculis augue, eget hendrerit elit dui vel elit.\n\nInteger ante eros, auctor eu, dapibus ac, ultricies vitae, lacus. Fusce accumsan mauris. Morbi felis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Maecenas convallis imperdiet nunc."

    message = vtkKWMessage()
    message.SetParent(notebook2.GetFrame(page_id))
    message.Create()
    message.SetText(lorem_ipsum)
    message.AppendText(lorem_ipsum)
    
    app.Script(
        "pack %s -side top -anchor nw -expand n -padx 2 -pady 2",
        message.GetWidgetName())

    # -----------------------------------------------------------------------

    # Create a disabled page

    page_id = notebook2.AddPage("Page Disabled")
    notebook2.SetPageEnabled(page_id, 0)
    
    app.Script(
        "pack %s -side top -anchor nw -expand y -fill both -padx 2 -pady 2", 
        notebook2.GetWidgetName())
    
    # -----------------------------------------------------------------------

    # Create a button inside one of the page (as a test)

    page_id = notebook2.AddPage("Button Page")
    
    pushbutton1 = vtkKWPushButton()
    pushbutton1.SetParent(notebook2.GetFrame(page_id))
    pushbutton1.Create()
    pushbutton1.SetText("A push button")
    
    app.Script("pack %s -side top -anchor c -expand y", 
                pushbutton1.GetWidgetName())
    
    return "TypeComposite"
Exemplo n.º 6
0
def vtkKWNotebookEntryPoint(parent, win):

    app = parent.GetApplication()

    # -----------------------------------------------------------------------

    # Create a notebook

    notebook1 = vtkKWNotebook()
    notebook1.SetParent(parent)
    notebook1.SetMinimumWidth(400)
    notebook1.SetMinimumHeight(200)
    notebook1.Create()

    app.Script("pack %s -side top -anchor nw -expand n -padx 2 -pady 2",
               notebook1.GetWidgetName())

    # Add some pages

    notebook1.AddPage("Page 1")

    notebook1.AddPage("Page Blue")
    notebook1.GetFrame("Page Blue").SetBackgroundColor(0.2, 0.2, 0.9)

    page_id = notebook1.AddPage("Page Red")
    notebook1.GetFrame(page_id).SetBackgroundColor(0.9, 0.2, 0.2)

    # -----------------------------------------------------------------------

    # Create a notebook inside one of the page (because we can)

    page_id = notebook1.AddPage("Sub Notebook")

    notebook2 = vtkKWNotebook()
    notebook2.SetParent(notebook1.GetFrame(page_id))
    notebook2.Create()
    notebook2.EnablePageTabContextMenuOn()
    notebook2.PagesCanBePinnedOn()
    notebook2.UseFrameWithScrollbarsOn()

    # -----------------------------------------------------------------------

    # Create a message inside one of the page (as a test for scrollbars)

    page_id = notebook2.AddPage("Page A")

    lorem_ipsum = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc felis. Nulla gravida. Aliquam erat volutpat. Mauris accumsan quam non sem. Sed commodo, magna quis bibendum lacinia, elit turpis iaculis augue, eget hendrerit elit dui vel elit.\n\nInteger ante eros, auctor eu, dapibus ac, ultricies vitae, lacus. Fusce accumsan mauris. Morbi felis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Maecenas convallis imperdiet nunc."

    message = vtkKWMessage()
    message.SetParent(notebook2.GetFrame(page_id))
    message.Create()
    message.SetText(lorem_ipsum)
    message.AppendText(lorem_ipsum)

    app.Script("pack %s -side top -anchor nw -expand n -padx 2 -pady 2",
               message.GetWidgetName())

    # -----------------------------------------------------------------------

    # Create a disabled page

    page_id = notebook2.AddPage("Page Disabled")
    notebook2.SetPageEnabled(page_id, 0)

    app.Script(
        "pack %s -side top -anchor nw -expand y -fill both -padx 2 -pady 2",
        notebook2.GetWidgetName())

    # -----------------------------------------------------------------------

    # Create a button inside one of the page (as a test)

    page_id = notebook2.AddPage("Button Page")

    pushbutton1 = vtkKWPushButton()
    pushbutton1.SetParent(notebook2.GetFrame(page_id))
    pushbutton1.Create()
    pushbutton1.SetText("A push button")

    app.Script("pack %s -side top -anchor c -expand y",
               pushbutton1.GetWidgetName())

    return "TypeComposite"