請幫忙!信息 -滾動窗口/面板製作Statictext全部在一條線上
程序:彈出框表示單擊listctrl項(「收件箱」)後生成的電子郵件消息。
情況:其中一封電子郵件的消息很長,部分消失了。需要一個垂直滾動條來閱讀所有內容!但是......
問題:一旦我改變wx.Panel沒有wx.ScrolledWindow或ScrolledPanel(都嘗試=相同),突然開始去全部在一行消息的文字...我更需要一個垂直滾動條,我需要+有一個水平滾動條來讀取所有。
如果我改回wx.Panel,文本再次包裝自己(沒有被告知)。它看起來整潔可愛......除了我仍然不能向下滾動閱讀其餘的內容。如果我放回ScrolledWindow,突然間所有的文字都會一行一行。我不明白。 :(爲什麼它會這樣對我?
通過水平滾動來讀取消息是非常不現實的,所以我確實需要獲得像之前一樣的StaticText,使用垂直滾動條滾動瀏覽我試過把main_message.Wrap(main_message.GetSize()。width)命令放進去,但它什麼也沒做。
我想讓它工作以便在需要的時候有一個垂直滾動條。 ..但不需要水平滾動條,即沒有瘋狂的文字突然決定它想要在一條線上。任何人都知道這是什麼做的?
儘可能縮小代碼,可以管理:
class Message(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, pos = (500, 100), size=(500, 500), style = wx.STAY_ON_TOP | wx.MAXIMIZE_BOX | wx.RESIZE_BORDER | wx.SYSTEM_MENU | wx.CAPTION)
self.basicpanel = wx.ScrolledWindow(self, -1)
self.basicpanel.SetScrollbars(1, 1, 1, 1)
self.basicpanel.SetBackgroundColour("medium goldenrod")
parent = self.GetParent()
message = parent.email
# email details e.g. sender, date, urgency, subject
sender_st = wx.StaticText(self.basicpanel, -1, "Sender:")
status_st = wx.StaticText(self.basicpanel, -1, "Status:")
date_st = wx.StaticText(self.basicpanel, -1, "Date:")
priority_st = wx.StaticText(self.basicpanel, -1, "Priority:")
subject_st = wx.StaticText(self.basicpanel, -1, "Subject:")
answer_sender = wx.StaticText(self.basicpanel, -1, message.sender)
answer_status = wx.StaticText(self.basicpanel, -1, message.status)
answer_date = wx.StaticText(self.basicpanel, -1, message.date)
answer_priority = wx.StaticText(self.basicpanel, -1, message.priority)
answer_subject = wx.StaticText(self.basicpanel, -1, message.subject)
# main body of email
main_message = wx.StaticText(self.basicpanel, -1, message.txt)
# create a box sizer to put in the email details like sender, date, et
self.messagebox = wx.StaticBox(self.basicpanel, -1, '', (5,5))
self.fgs_message = wx.FlexGridSizer(3, 4, 5, 15)
self.fgs_message.AddMany([(sender_st, 1, wx.EXPAND), (answer_sender, 1, wx.EXPAND), (status_st, 1, wx.EXPAND), (answer_status, 1, wx.EXPAND), (date_st, 1, wx.EXPAND), (answer_date, 1, wx.EXPAND), (priority_st, 1, wx.EXPAND), (answer_priority, 1, wx.EXPAND), (subject_st, 1, wx.EXPAND), (answer_subject, 1, wx.EXPAND)])
self.boxmessagesizer = wx.StaticBoxSizer(self.messagebox, wx.VERTICAL)
self.boxmessagesizer.Add(self.fgs_message, 1, wx.ALL, 5)
# create a sizer to include the above details and the main message or body of email
self.messagebasicsizer = wx.BoxSizer(wx.VERTICAL)
self.messagebasicsizer.Add(self.boxmessagesizer, 0, wx.EXPAND | wx.ALL, 10)
self.messagebasicsizer.Add(main_message, 1, wx.EXPAND | wx.ALL, 10)
# create buttons at the bottom and a horizontal sizer to put them on same line
self.buttonreply = wx.Button(self.basicpanel, 1, 'Reply', (20,10))
self.buttondelete = wx.Button(self.basicpanel, 1, 'Close + Delete', (40, 10))
self.buttonsave = wx.Button(self.basicpanel, 1, 'Close + Save', (40,10))
self.horisizer = wx.BoxSizer(wx.HORIZONTAL)
self.horisizer.AddMany([(self.buttonreply, 0, wx.EXPAND | wx.ALL, 10), (self.buttondelete, 0, wx.EXPAND | wx.ALL, 10), (self.buttonsave, 0, wx.EXPAND | wx.ALL, 10)])
# add buttons to sizer with message details and message
self.messagebasicsizer.Add(self.horisizer, 0, wx.EXPAND | wx.ALIGN_CENTRE | wx.ALL, 10)
self.basicpanel.SetSizer(self.messagebasicsizer)
self.Bind(wx.EVT_BUTTON, self.OnDestroy)
self.Show(True)