def create(self): self.native = WinForms.TextBox() self.native.Multiline = False self.native.DoubleClick += self.winforms_double_click self.native.TextChanged += self.winforms_text_changed self.native.Validated += self.winforms_validated self.error_provider = WinForms.ErrorProvider() self.error_provider.SetIconAlignment( self.native, WinForms.ErrorIconAlignment.MiddleRight) self.error_provider.SetIconPadding(self.native, -20) self.error_provider.BlinkStyle = WinForms.ErrorBlinkStyle.NeverBlink
def create(self): self._container = self self.native = WinForms.ListView() self.native.View = WinForms.View.Details dataColumn = [] for heading in self.interface.headings: col = WinForms.ColumnHeader() col.Text = heading dataColumn.append(col) self.native.FullRowSelect = True self.native.Multiselect = self.interface.multiple_select self.native.Columns.AddRange(dataColumn)
def insert(self, index, item): self.native.BeginUpdate() item._impl = WinForms.ListViewItem([ str(getattr(item, attr)) for attr in self.interface._accessors ]) self.native.Items.Insert(index, item._impl) self.native.EndUpdate()
def create(self): # because https://stackoverflow.com/a/612234 self.native = WinForms.RichTextBox() self.native.Multiline = True self.native.TextChanged += self.winforms_text_changed self.native.Enter += self.winforms_enter self.native.Leave += self.winforms_leave self._placeholder = None
def create(self): self.native = WinForms.TrackBar() self.native.Scroll += self.winforms_scroll self.native.MouseDown += self.winforms_mouse_down self.native.MouseUp += self.winforms_mouse_up self.set_enabled(self.interface._enabled) self.native.Minimum = 0 self.set_tick_count(self.interface.tick_count)
def winforms_retrieve_virtual_item(self, sender, e): # Because ListView is in VirtualMode, it's necessary implement # VirtualItemsSelectionRangeChanged event to create ListViewItem when it's needed if self._cache and e.ItemIndex >= self._first_item and \ e.ItemIndex < self._first_item + len(self._cache): e.Item = self._cache[e.ItemIndex - self._first_item] else: e.Item = WinForms.ListViewItem(self.row_data(self.interface.data[e.ItemIndex]))
def update_data(self): self.native.BeginUpdate() self.native.Items.Clear() items = [] for item in self.interface.data: item._impl = WinForms.ListViewItem(self.row_data(item)) items.append(item._impl) self.native.Items.AddRange(items) self.native.EndUpdate()
def set_tooltip(el: toga.Label, text): if IS_WINDOWS: tt = WinForms.ToolTip() tt.IsBalloon = True tt.InitialDelay = 500 tt.ReshowDelay = 800 tt.AutoPopDelay = 15000 tt.SetToolTip(el._impl.native, text) elif IS_MAC: pass # TODO, below snipets does not work
def winforms_cache_virtual_items(self, sender, e): if self._cache and e.StartIndex >= self._first_item and \ e.EndIndex <= self._first_item + len(self._cache): # If the newly requested cache is a subset of the old cache, # no need to rebuild everything, so do nothing return # Now we need to rebuild the cache. self._first_item = e.StartIndex new_length = e.EndIndex - e.StartIndex + 1 self._cache = [] # Fill the cache with the appropriate ListViewItems. for i in range(new_length): self._cache.append(WinForms.ListViewItem(self.row_data(self.interface.data[i])))
def add_content(self, label, widget): widget.viewport = WinFormsViewport(self.native, self) widget.frame = self # Add all children to the content widget. for child in widget.interface.children: child._impl.container = widget item = WinForms.TabPage() item.Text = label # Enable AutoSize on the container to fill # the available space in the OptionContainer. widget.AutoSize = True item.Controls.Add(widget.native) self.native.Controls.Add(item)
def create(self): self.native = WinForms.ListView() self.native.View = WinForms.View.Details self._cache = [] self._first_item = 0 dataColumn = [] for i, (heading, accessor) in enumerate( zip(self.interface.headings, self.interface._accessors)): dataColumn.append(self._create_column(heading, accessor)) self.native.FullRowSelect = True self.native.MultiSelect = self.interface.multiple_select self.native.DoubleBuffered = True self.native.VirtualMode = True self.native.Columns.AddRange(dataColumn) self.native.ItemSelectionChanged += self.winforms_item_selection_changed self.native.RetrieveVirtualItem += self.winforms_retrieve_virtual_item self.native.CacheVirtualItems += self.winforms_cache_virtual_items self.native.VirtualItemsSelectionRangeChanged += self.winforms_virtual_item_selection_range_changed
def create(self): self.native = WinForms.LinkLabel() self.native.LinkColor = Color.Black self.native.LinkClicked += WinForms.LinkLabelLinkClickedEventHandler( self.interface._link_clicked )
def create(self): self.native = WinForms.NumericUpDown()
def create(self): self.native = WinForms.TreeView()
def create(self): self.native = WinForms.Button() self.native.Click += self.winforms_click self.set_enabled(self.interface._enabled)
def create(self): self.native = WinForms.Panel() self.native.interface = self.interface
def create(self): self.native = WinForms.DateTimePicker() self.native.Format = WinForms.DateTimePickerFormat.Time self.native.ShowUpDown = True
def create(self): self.native = WinForms.Label()
def create(self): self.native = WinForms.CheckBox() self.native.CheckedChanged += self.winforms_checked_changed
def create(self): self.native = WinForms.DateTimePicker()
def create(self): self.native = WinForms.TabControl()
def insert(self, index, item): item._impl = WinForms.ListViewItem( [getattr(item, attr) for attr in self.interface._accessors]) self.native.Items.Insert(index, item._impl)
def create(self): self.native = WinForms.SplitContainer() self.native.interface = self.interface self.native.Resize += self.on_resize self.native.SplitterMoved += self.on_resize self.ratio = None
def create(self): self.native = WinForms.Panel() self.native.interface = self.interface self.native.AutoScroll = True self.native.Scroll += self.winforms_scroll self.native.MouseWheel += self.winforms_scroll
def create(self): self.native = WinForms.ProgressBar()
def create(self): self.native = WinForms.TextBox() self.native.Multiline = False
def create(self): self.native = WinForms.PictureBox() self.native.interface = self.interface self.native.SizeMode = WinForms.PictureBoxSizeMode.StretchImage
def create(self): self.native = WinForms.Panel() self.native.interface = self.interface self.native.AutoScroll = True
def setUp(self): self.loop = proactor.WinformsProactorEventLoop() # asyncio.set_event_loop(self.loop) self.app_context = WinForms.ApplicationContext()
def create(self): self.native = WinForms.DateTimePicker() self.native.ValueChanged += self.winforms_value_changed self.native.Format = WinForms.DateTimePickerFormat.Time self.native.ShowUpDown = True