2020년 12월 5일 토요일

[IronPython] WPF Tab Layout

WPF Tab Layout

import clr
clr.AddReference("PresentationFramework")
clr.AddReference("PresentationCore");
clr.AddReference('System.Data')
clr.AddReference('System.Windows.Forms')

import System
from System import *
from System.Data import *
from System.Type import GetType
from System.Threading.Tasks import Task
from System.Windows import *
from System.Windows.Controls import *
from System.Windows.Controls.Primitives import *
from System.Windows.Media import *
from System.Windows.Media.Imaging import *
from System.Windows.Media.Effects import *
from System.Windows.Shapes import Rectangle
from System.Windows.Data import Binding
from System.Windows.Ink import Stroke
from System.Windows.Forms import ( FolderBrowserDialog, DialogResult )
from Microsoft.Win32 import ( OpenFileDialog, SaveFileDialog )

import hbox 

class WpfTab():
    def __init__(self,items=None):
        self.ctrl = TabControl()
        self.ctrl.Margin =  System.Windows.Thickness(15)
        if items and type(items) == dict:
            for k,v in items.items(): self.add_item( k, v) 
    def add_item(self,label,ctrl):
        tab = TabItem()
        tab.Header = label
        tab.Content = ctrl
        self.ctrl.Items.Add(tab)

if __name__ == "__main__":
    import win
    app = win.Win("HSplit Demo",320,240)
    b1 = Button(); b1.Content = "Left"
    b2 = Button(); b2.Content = "Right"
    tab = WpfTab( { "Tab1" : b1, "Tab2" : b2 } )
    app.set_content(tab.ctrl)
    app.run()
    

댓글 없음:

댓글 쓰기