コード例 #1
0
ファイル: main.py プロジェクト: madlinux/ironpython
    def populate_login_panel(self):
        button = Button()
        button.Content = '  Login  '
        button.FontSize = 16
        button.Margin = Thickness(5, 5, 5, 5)
        button.HorizontalAlignment = HorizontalAlignment.Stretch
        
        remember_me = CheckBox()
        remember_me.IsChecked = True
        remember_me.Margin = Thickness(5, 5, 5, 5)
        remember_me.Content = 'Remember'
        
        button_pane = StackPanel()
        button_pane.Children.Add(button)
        button_pane.Children.Add(remember_me)

        username = TextBox()
        username.FontSize = 16
        username.Width = 200
        username.Margin = Thickness(5, 5, 5, 5)

        password = PasswordBox()
        password.FontSize = 16
        password.Width = 200
        password.Margin = Thickness(5, 5, 5, 5)
        
        def HandleEnterKey(s, event):
            if event.Key == Key.Enter:
                event.Handled = True
                self.onLogin(None, None)
        
        password.KeyDown += HandleEnterKey
        if CheckStored():
            stored_username, stored_password = GetStored()
            username.Text = stored_username
            password.Password = stored_password

        entry_panel = StackPanel()
        entry_panel.HorizontalAlignment = HorizontalAlignment.Stretch
        entry_panel.Children.Add(username)
        entry_panel.Children.Add(password)

        self.bottom_panel.Children.Add(entry_panel)
        self.bottom_panel.Children.Add(button_pane)

        self.button = button
        self.remember_me = remember_me
        self.username_box = username
        self.password_box = password
        button.Click += self.onLogin
        
        self.msg = TextBlock()
        self.msg.Text = '      Login       '
        self.msg.FontSize = 16
        self.msg.HorizontalAlignment = HorizontalAlignment.Center
        self.msg.VerticalAlignment = VerticalAlignment.Center
        self.bottom_panel.Children.Add(self.msg)
コード例 #2
0
 def __init__(self, h):
     self.ctrl = CheckBox()
     self.ctrl.VerticalAlignment = VerticalAlignment.Center
     self.ctrl.VerticalContentAlignment = VerticalAlignment.Center
     self.Initialize(h)
     if h.get('label'): self.ctrl.Content = h['label']
     if h.get('fontsize'): self.SetFontSize(h['fontsize'])
     if h.get('handler'): self.ctrl.Click += h['handler']
コード例 #3
0
    def __init__(self, model):
        """
        Display the GUI using data in the model class
        """
        self.model = model

        stream = StreamReader(
            os.path.join(os.path.dirname(__file__), GUI_XAML_FILE))
        self.window = XamlReader.Load(stream.BaseStream)

        self.window.Title = self.model.title

        self.lblPrompt = LogicalTreeHelper.FindLogicalNode(
            self.window, "lblPrompt")
        self.lblPrompt.Content = self.model.prompt

        self.choicesGrid = LogicalTreeHelper.FindLogicalNode(
            self.window, "choicesGrid")
        self.choicesChk = System.Array.CreateInstance(
            CheckBox, len(self.model.choiceList))
        self.choicesLabels = System.Array.CreateInstance(
            Label, len(self.model.choiceList))

        for ii, choiceName in enumerate(self.model.choiceList):
            self.choicesGrid.RowDefinitions.Add(RowDefinition())

            self.choicesLabels[ii] = Label()
            self.choicesLabels[ii].Content = choiceName
            self.choicesLabels[ii].SetValue(Grid.RowProperty, ii)
            self.choicesLabels[ii].SetValue(Grid.ColumnProperty, 0)

            if self.model.alignChoices.lower() == 'left':
                self.choicesLabels[
                    ii].HorizontalAlignment = HorizontalAlignment.Left
            else:
                self.choicesLabels[
                    ii].HorizontalAlignment = HorizontalAlignment.Right
            self.choicesGrid.Children.Add(self.choicesLabels[ii])

            self.choicesChk[ii] = CheckBox()
            self.choicesChk[ii].Margin = Thickness(7.0, 7.0, 2.0, 2.0)
            self.choicesChk[ii].SetValue(Grid.RowProperty, ii)
            self.choicesChk[ii].SetValue(Grid.ColumnProperty, 1)
            self.choicesChk[ii].HorizontalAlignment = HorizontalAlignment.Left
            self.choicesGrid.Children.Add(self.choicesChk[ii])

        self.btCancel = LogicalTreeHelper.FindLogicalNode(
            self.window, "btCancel")
        self.btCancel.Click += self.cancel_clicked
        self.btOK = LogicalTreeHelper.FindLogicalNode(self.window, "btOK")
        self.btOK.Click += self.ok_clicked

        self.window.Show()
        self.window.Closed += lambda s, e: self.window.Dispatcher.InvokeShutdown(
        )
        System.Windows.Threading.Dispatcher.Run()
コード例 #4
0
ファイル: WPFControls.py プロジェクト: madlinux/ironpython
 def createComboAndCheck(self, grid):
    panel = StackPanel()
    
    label = Label()
    label.Content = "CheckBox & ComboBox"
    label.FontSize = 16
    label.Margin = Thickness(10)
    
    check = CheckBox()
    check.Content = "CheckBox"
    check.Margin = Thickness(10)
    check.FontSize = 16
    check.IsChecked = True
    def action(s, e):
       checked = check.IsChecked
       self.label.Content = "CheckBox IsChecked = %s" % checked
    check.Checked += action
    check.Unchecked += action
    
    combo = ComboBox()
    for entry in ("A ComboBox", "An Item", "The Next One", "Another"):
       item = ComboBoxItem()
       item.Content = entry
       item.FontSize = 16
       combo.Items.Add(item)
    combo.SelectedIndex = 0
    combo.Height = 26
    def action(s, e):
       selected = combo.SelectedIndex
       self.label.Content = "ComboBox SelectedIndex = %s" % selected
    combo.SelectionChanged += action
    combo.FontSize = 16
    combo.Margin = Thickness(10)
    
    panel.Children.Add(label)
    panel.Children.Add(combo)
    panel.Children.Add(check)
    SetGridChild(grid, panel, 0, 1, "ComboBox & CheckBox")
コード例 #5
0
ファイル: Facebook.py プロジェクト: ailen0ada/Apricot
		stack = Stack[String]()
	
		for window in Application.Current.Windows:
			if clr.GetClrType(Agent).IsInstanceOfType(window):
				for message in window.Balloon.Messages:
					stack.Push(String.Format("\"{0}: {1}\"", sb.ToString(), Regex.Replace(message.Text, Environment.NewLine, String.Empty, RegexOptions.CultureInvariant)))

		while stack.Count > 0:
			comboBoxItem = ComboBoxItem()
			comboBoxItem.Content = stack.Pop()
			comboBox.Items.Add(comboBoxItem)

			if comboBox.SelectedItem is None:
				comboBox.SelectedItem = comboBoxItem
	
		checkBox = CheckBox()
		checkBox.Margin = Thickness(10, 0, 0, 0)
		checkBox.Padding = Thickness(5, 0, 5, 0)
		checkBox.HorizontalAlignment = HorizontalAlignment.Left
		checkBox.VerticalAlignment = VerticalAlignment.Center

		def onPostClick(source, rea):
			if not String.IsNullOrEmpty(comboBox.Text):
				fileName = None

				if checkBox.IsChecked:
					currentDirectory = Directory.GetCurrentDirectory()

					openFileDialog = OpenFileDialog()
					openFileDialog.Multiselect = False