WPF Combo Box
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 ctrl
class WpfCombo(ctrl.WpfCtrl):
def __init__(self,handler=None,items=None,selected=0,**kwargs):
self.ctrl = ComboBox()
self.ctrl.IsEditable=True
self.ctrl.IsReadOnly=False
self.init(**kwargs)
if handler: self.ctrl.SelectionChanged += handler
if items:
self.ctrl.ItemsSource = items
self.ctrl.SelectedIndex = selected
def get_value(self): return ctrl.Text
def get_added_item(self,args): return args.AddedItems[0]
choice_ctrl = None
if __name__ == "__main__":
def combo_handler(s,e):
if len(e.AddedItems) > 0:
print( e.AddedItems[0] )
def button_handler(s,e):print( choice_ctrl.ctrl.Text )
import win
app = win.Win("Button Demo",320,240)
choice_ctrl = WpfCombo(items=("1st","2nd","3rd"),selected=0, handler=combo_handler)
app.set_content(choice_ctrl.ctrl)
b = Button(); b.Content = "Button"; b.Click += button_handler
app.add_statusbar(b)
app.run()
댓글 없음:
댓글 쓰기