ใช้ SPE ในการเขียน wxPython
ผมรัน แต่มันไม่ออกตามที่ผมคิด มันมี หน้าต่างสีขาวๆ ออกมา แว๊วเดียวมันก็หายไปทันที คิดว่าน่าจะบอก error กับเรา
code ของผมมันต้องมีปัญหาแน่ๆ แต่ผมไม่รู้ว่าจะแสดง error ได้อย่างไร
เซ็ตตรงไหนครับ ช่วยบอกหน่อยครับผม
สั่ง run จาก command line น่าจะแสดง exception หรือ error ครับ ยกเว้นว่า try...except ไว้แบบครอบจักรวาล และใน block except ไม่ได้สั่งให้มัน print error ออกมา
ฟังแล้วอาการเหมือนลืมเรียก app.MainLoop() รึเปล่าครับ
code ตามนี้เลยครับ บางคนอาจรันได้หรือเปล่าไม่ทราบ ผมรันใน windows xp ไม่ได้ครับ
import wx import time import locale
class Locale(wx.Frame): def init(self, parent, id, title): wx.Frame.init(self, parent, id, title, size=(250, 420))
panel = wx.Panel(self, -1) tm = time.localtime() font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD) us = wx.StaticText(self, -1, 'United States', (25, 20)) us.SetFont(font) wx.StaticLine(self, -1, (25, 50), (200 ,1)) locale.setlocale(locale.LC_ALL, '') date = time.strftime('%x', tm) time_ = time.strftime('%X', tm) curr = locale.currency(100000) wx.StaticText(self, -1, 'date: ', (25, 70)) wx.StaticText(self, -1, 'time: ', (25, 90)) wx.StaticText(self, -1, 'currency: ', (25, 110)) wx.StaticText(self, -1, str(date), (125, 70)) wx.StaticText(self, -1, str(time_), (125, 90)) wx.StaticText(self, -1, str(curr), (125, 110)) de = wx.StaticText(self, -1, 'Germany', (25, 150)) de.SetFont(font) wx.StaticLine(self, -1, (25, 180), (200,1)) locale.setlocale(locale.LC_ALL, ('de_DE', 'UTF8')) date = time.strftime('%x', tm) time_ = time.strftime('%X', tm) curr = locale.currency(100000) wx.StaticText(self, -1, 'date: ', (25, 200)) wx.StaticText(self, -1, 'time: ', (25, 220)) wx.StaticText(self, -1, 'currency: ', (25, 240)) wx.StaticText(self, -1, date, (125, 200)) wx.StaticText(self, -1, time_, (125, 220)) wx.StaticText(self, -1, curr, (125, 240)) de = wx.StaticText(self, -1, 'Slovakia', (25, 280)) de.SetFont(font) wx.StaticLine(self, -1, (25, 310), (200,1)) locale.setlocale(locale.LC_ALL, ('sk_SK', 'UTF8')) date = time.strftime('%x', tm) time_ = time.strftime('%X', tm) curr = locale.currency(100000) wx.StaticText(self, -1, 'date: ', (25, 330)) wx.StaticText(self, -1, 'time: ', (25, 350)) wx.StaticText(self, -1, 'currency: ', (25, 370)) wx.StaticText(self, -1, str(date), (125, 330)) wx.StaticText(self, -1, str(time_), (125, 350)) wx.StaticText(self, -1, str(curr), (125, 370)) self.Centre() self.Show(True)
app = wx.App() Locale(None, -1, 'Locale') app.MainLoop()
สั่ง run จาก command line น่าจะแสดง exception หรือ error ครับ ยกเว้นว่า try...except ไว้แบบครอบจักรวาล และใน block except ไม่ได้สั่งให้มัน print error ออกมา
ฟังแล้วอาการเหมือนลืมเรียก app.MainLoop() รึเปล่าครับ
code ตามนี้เลยครับ
บางคนอาจรันได้หรือเปล่าไม่ทราบ
ผมรันใน windows xp ไม่ได้ครับ
!/usr/bin/python
locale.py
import wx
import time
import locale
class Locale(wx.Frame):
def init(self, parent, id, title):
wx.Frame.init(self, parent, id, title, size=(250, 420))
app = wx.App()
Locale(None, -1, 'Locale')
app.MainLoop()