示例#1
0
def get_console_block():
    block = TextBlock()
    block.FontSize = 15
    block.Margin = Thickness(0, 0, 0, 0)
    block.TextWrapping = TextWrapping.Wrap
    block.FontFamily = FontFamily("Consolas, Global Monospace")
    return block
示例#2
0
def get_console_block():
    block = TextBlock()
    block.FontSize = 15
    block.Margin = Thickness(0, 0, 0, 0)
    block.TextWrapping = TextWrapping.Wrap
    block.FontFamily = FontFamily("Consolas, Global Monospace")
    return block
示例#3
0
    def populate_tweets(self, data):
        statuses = TwitterStatusReader().read(data)
        if not statuses:
            self.msg.Text = 'No tweets found!'
            return
            
        grid = Grid()
        grid.ShowGridLines = True
        self.top_panel.Content = grid

        first_column = ColumnDefinition()
        first_column.Width = GridLength(115.0)
        grid.ColumnDefinitions.Add(first_column)
        grid.ColumnDefinitions.Add(ColumnDefinition())
        
        for i in range(len(statuses)):
            grid.RowDefinitions.Add(RowDefinition())

        def configure_block(block, col, row):
            block.FontSize = 14
            block.Margin = Thickness(5)
    
            block.HorizontalAlignment = HorizontalAlignment.Left
            block.VerticalAlignment = VerticalAlignment.Center
            grid.SetRow(block, row)
            grid.SetColumn(block, col)

        for row, status in enumerate(statuses):
            name = status['name']
            text = status['text']
            
            block1 = HyperlinkButton()
            block1.Content = name
            block1.NavigateUri = Uri('http://twitter.com/%s' % name)
            
            # this should open the link in a new window 
            # but causes link to not function at all on Safari
            # It works for IE though
            #block1.TargetName = '_blank' 
            
            block1.FontWeight = FontWeights.Bold
            configure_block(block1, 0, row)
            
            block2 = TextBlock()
            block2.Text = text
            block2.TextWrapping = TextWrapping.Wrap
            configure_block(block2, 1, row)
            
            grid.Children.Add(block1)
            grid.Children.Add(block2)
 def _create_body(self, message, value, **extra):
     _label = Label()
     textblock = TextBlock()
     textblock.Text = message
     textblock.TextWrapping = TextWrapping.Wrap
     _label.Content = textblock
     _label.Margin = Thickness(10)
     _label.SetValue(Grid.ColumnSpanProperty, 2)
     _label.SetValue(Grid.RowProperty, 0)
     self.Content.AddChild(_label)
     selector = self._create_selector(value, **extra)
     if selector:
         self.Content.AddChild(selector)
         selector.Focus()
示例#5
0
 def _create_body(self, message, value, **extra):
     _label = Label()
     textblock = TextBlock()
     textblock.Text = message
     textblock.TextWrapping = TextWrapping.Wrap
     _label.Content = textblock
     _label.Margin = Thickness(10)
     _label.SetValue(Grid.ColumnSpanProperty, 2)
     _label.SetValue(Grid.RowProperty, 0)
     self.Content.AddChild(_label)
     selector = self._create_selector(value, **extra)
     if selector:
         self.Content.AddChild(selector)
         selector.Focus()
示例#6
0
 def createTextBlockAndHyperlink(self, grid):
    textblock = TextBlock()
    textblock.TextWrapping = TextWrapping.Wrap
    textblock.Background = Brushes.AntiqueWhite
    textblock.TextAlignment = TextAlignment.Center 
    textblock.Inlines.Add(Bold(Run("TextBlock")))
    textblock.Inlines.Add(Run(" is designed to be "))
    textblock.Inlines.Add(Italic(Run("lightweight")))
    textblock.Inlines.Add(Run(", and is geared specifically at integrating "))
    textblock.Inlines.Add(Italic(Run("small")))
    textblock.Inlines.Add(Run(" portions of flow content into a UI. "))
    
    link = Hyperlink(Run("A Hyperlink - Click Me"))
    def action(s, e):
       self.label.Content = "Hyperlink Clicked"
    link.Click += action
    textblock.Inlines.Add(link)
    SetGridChild(grid, textblock, 2, 2, "TextBlock")
示例#7
0
 def createScrollViewer(self, grid):
    scroll = ScrollViewer()
    scroll.Height = 200
    scroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto
    scroll.HorizontalAlignment = HorizontalAlignment.Stretch
    scroll.VerticalAlignment = VerticalAlignment.Stretch
    panel = StackPanel()
    text = TextBlock()
    text.TextWrapping = TextWrapping.Wrap
    text.Margin = Thickness(0, 0, 0, 20)
    text.Text = "A ScrollViewer.\r\n\r\nScrollbars appear as and when they are needed...\r\n"
    
    rect = Rectangle()
    rect.Fill = GetLinearGradientBrush()
    rect.Width = 500
    rect.Height = 500
    
    panel.Children.Add(text)
    panel.Children.Add(rect)
                
    scroll.Content = panel;
    SetGridChild(grid, scroll, 1, 2, "ScrollViewer")