
listBox, column=0! /%i)
self, sticky=N)
selfpython
# -*- coding:
selfusr/, column=2, height=1)
selfbin/Item%d'.grid(row=0.listBox.insert(i: utf8 -*-
from Tkinter import *
class Select(Frame).label = Label(self, 1][self.listBox, master)
self:
self:
def __init__(self.listBox.hideList = True
for i in xrange(10).buttonTkinter居然没有这种组件, column=1)
self.triggle)
self.listBox = Listbox(self.grid(row=0:
Frame.config(height=[self, text=', text=&quot.size().grid()
def triggle(self).label.grid(row=0, command=self, '.__init__(self, sticky=N)
self.hideList ^= 1
self, master=None),所以就只能模拟了
#V'选择项目&quot, sticky=N)
self.button = Button(self.hideList])
app = Select()
app
from tkinter import *colors = ['red', 'green', 'orange', 'white', 'yellow', 'blue']
r = 0
for c in colors:
Label(text=c, relief=RIDGE, width=25).grid(row=r, column=0)
Entry(bg=c, relief=SUNKEN, width=50).grid(row=r, column=1)
r += 1
///sticky=NSEW,rowconfigure扩展
"add a label on the top and form resizing"
from tkinter import *
colors = ['red', 'white', 'blue']
def gridbox(root):
Label(root, text='Grid').grid(columnspan=2)
row = 1
for color in colors:
lab = Label(root, text=color, relief=RIDGE, width=25)
ent = Entry(root, bg=color, relief=SUNKEN, width=50)
lab.grid(row=row, column=0, sticky=NSEW)
ent.grid(row=row, column=1, sticky=NSEW)
root.rowconfigure(row, weight=1)
row += 1
root.columnconfigure(0, weight=1)
root.columnconfigure(1, weight=1)
def packbox(root):
Label(root, text='Pack').pack()
for color in colors:
row = Frame(root)
lab = Label(row, text=color, relief=RIDGE, width=25)
ent = Entry(row, bg=color, relief=SUNKEN, width=50)
row.pack(side=TOP, expand=YES, fill=BOTH)
lab.pack(side=LEFT, expand=YES, fill=BOTH)
ent.pack(side=RIGHT, expand=YES, fill=BOTH)
root = Tk()
gridbox(Toplevel(root))
packbox(Toplevel(root))
Button(root, text='Quit', command=root.quit).pack()
mainloop()
columnspan=2 跨两行 row column
使用手工定义的方式实现显示Grid边框线
<UserControlx:Class="SilverlightApplicationGridBorderSample.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<Grid
x:Name="LayoutRoot"
Background="White">
<Grid.Resources>
<Style
TargetType="TextBlock">
<Setter
Property="FontSize"
Value="30"></Setter>
<Setter
Property="VerticalAlignment"
Value="Center"></Setter>
</Style>
<Style
TargetType="Border">
<Setter
Property="BorderBrush"
Value="LightGray"></Setter>
<Setter
Property="BorderThickness"
Value="1"></Setter>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock
Text="左上角"></TextBlock>
<TextBlock
Text="左下角"
Grid.Row="1"></TextBlock>
<TextBlock
Text="右上角"
Grid.Column="1"></TextBlock>
<TextBlock
Text="右下角"
Grid.Row="1"
Grid.Column="1"></TextBlock>
<!--添加4个边框-->
<Border></Border>
<Border
Grid.Row="1"></Border>
<Border
Grid.Column="1"></Border>
<Border
Grid.Row="1"
Grid.Column="1"></Border>
</Grid>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)