คนยังไง?

เวลาเราคุยกันถึงบุคคลที่สาม คำถามหนึ่งที่เราได้ยินกันตลอด ไม่ว่าจะบ่อยหรือไม่แค่ไหน ก็คือคำถามแนวว่า “คนนี้เป็นคนยังไง”

ไม่รู้ว่าผมอยู่กับคอมพิวเตอร์ ซึ่งสามารถอธิบายอะไรๆ ได้ง่ายๆ นานเกินไปรึเปล่า แต่ผมไม่สามารถอธิบายคนๆ หนึ่งด้วยในการคุยกันไม่เกินครึ่งชั่วโมงเช่นนี้ กับคนคนหนึ่งที่ใช้เวลานับสิบปีในการพัฒนาความคิดและจิตใจ มันเป็นไปได้หรือที่เราจะจำกัดความเขาไว้ด้วยคำพูดทำนองว่า “คนนี้เป็นคนดี”, “อบอุ่นดีนะ” หรือ “เป็นคนแข็งๆ น่ะ”

ชื่อบล็อกของผมที่ lewcpe.exteen.com ใช้ชื่อว่าเพราะคนเรามีหลายด้าน และก็นับว่าน่าพอใจทีเดียวกับเนื้อหาทีออกมา ให้หลายๆ คนแปลกใจเพราะไม่ใช่ว่าคนอย่างผม ที่ถูกเขาจำกัดลักษณะไว้ด้วยคำพูดสั้นๆ อย่างนั้นจะเขียนมันออกมาได้

ความเป็นจริงง่ายๆ ที่เราทุกคนรู้กันเช่นกว่า คนที่รักแม่ที่สุดก็ต้องเคยทะเลาะกับแม่บ้าง และไม่น้อยที่ลูกที่หนีจากบ้านไปกลายเป็นคนที่กลับมาเลี้ยงดูพ่อแม่เมื่อแก่เฒ่า

ขณะที่เราปฏิเสธสัญชาตญาณในตัวเรา ที่มักจะมองลักษณะคนจากภายนอกในแบบคร่าวๆ ไม่ได้

แต่ก็คงดีไม่น้อย ถ้าเราจะมองคนให้ลึกและรอบด้านกันมากกว่านั้น

 

Mini Upgrade

ด้วยความที่อยากเขียนโปรแกรมมาลงบล็อกเรื่อยๆ ตอนนี้เลยเพิ่ม FTF Formatter เข้ามาอีกตัว จะได้เอาโค้ดมาลงง่ายๆ

ปัญหาที่เกิดขึ้นคือในตอนนี้ใช้ ModRewrite ให้มันชี้คนที่เข้าเว็บมา ให้มาโผล่ /blog/ แทน ซึ่งก็เวิร์คดี แต่ปรากฏว่า PHP มันจะงงว่าตกลงมันทำงานที่ Path ไหนกันแน่ ตัว FTF เลยเดี๊ยงสนิท

วิธีแก้ก็ปิด ModRewrite ทิ้ง แล้วใช้ Redirect แทน ทีนี้ใครเข้าเว็บผมก็จะโดนแก้ URL เป็นอย่างที่ผมชอบแล้ว สบายไปอีกแบบ

 

Bug

As I’m working in my personal project about Thai language. I try to learn GUI programming with wxPython anf face some problem in following code.

[ftf w=”400″ h=”300″ def=”python.xml”]#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.4 on Tue Mar 21 20:06:06 2006

import wx
import codecs

class MainFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MainFrame.__init__
kwds[“style”] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)

# Tool Bar
self.wdMainFrameToolBar = wx.ToolBar(self, -1)
self.SetToolBar(self.wdMainFrameToolBar)
self.wdMainFrameToolBar.AddLabelTool(wx.NewId(), “Auto”, wx.Bitmap(“C:\\Documents and Settings\\Wason Lewlompaisal\\My Documents\\My Download\\more-smilies\\tango\\dialog-information.png”, wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_CHECK, “Break Thai Word Automatic”, “”)
self.wdMainFrameToolBar.AddLabelTool(wx.NewId(), “ShowZWSP”, wx.Bitmap(“C:\\Documents and Settings\\Wason Lewlompaisal\\My Documents\\My Download\\more-smilies\\tango\\applications-multimedia.png”, wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_CHECK, “Show Zero Width Space in Text Box”, “”)
# Tool Bar end
self.SingleTextControl = wx.TextCtrl(self, -1, “”, style=wx.TE_MULTILINE)

self.__set_properties()
self.__do_layout()

self.Bind(wx.EVT_TOOL, self.OnAutoWordBreak, id=-1)
self.Bind(wx.EVT_TOOL, self.OnShowZWSP, id=-1)
self.Bind(wx.EVT_TEXT, self.OnTextChange, self.SingleTextControl)
# end wxGlade

def __set_properties(self):
# begin wxGlade: MainFrame.__set_properties
self.SetTitle(“Thai Input Demo”)
self.SetSize((400, 300))
self.wdMainFrameToolBar.Realize()
# end wxGlade

def __do_layout(self):
# begin wxGlade: MainFrame.__do_layout
MainGridSizer = wx.GridSizer(1, 1, 0, 0)
MainGridSizer.Add(self.SingleTextControl, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
self.SetAutoLayout(True)
self.SetSizer(MainGridSizer)
self.Layout()
# end wxGlade

def OnAutoWordBreak(self, event): # wxGlade: MainFrame.
print “Event handler `OnAutoWordBreak’ not implemented!”
allText = self.SingleTextControl.GetValue()
print “ALLTEXT>>”, repr(allText)
event.Skip()

def OnShowZWSP(self, event): # wxGlade: MainFrame.
print “Event handler `OnShowZWSP’ not implemented!”
event.Skip()

def OnTextChange(self, event): # wxGlade: MainFrame.
sentence = self.ExtractCurrentSentence()
print “Current Sentence::”, sentence.encode(“utf-8”)

def ExtractCurrentSentence(self):
allText = self.SingleTextControl.GetValue()
print “ALLTEXT>>”, repr(allText)
curPos = self.SingleTextControl.GetLastPosition()
sentenceList = allText.split(u” “)
for word in sentenceList:
print word.encode(“utf-8”), “==>”, len(word)
runPos = 0;
curSentence = 0;
while (True):
if (len(sentenceList[curSentence]) + runPos > curPos – 1):
break
runPos += len(sentenceList[curSentence]) + 1
curSentence += 1
return sentenceList[curSentence]

# end of class MainFrame

class ThaiBreakApp(wx.App):
def OnInit(self):
wx.InitAllImageHandlers()
wdMainFrame = MainFrame(None, -1, “”)
self.SetTopWindow(wdMainFrame)
wdMainFrame.Show()
return 1

# end of class ThaiBreakApp

if __name__ == “__main__”:
app = ThaiBreakApp(0)
app.MainLoop()
[/ftf]

Program seems to be fine at start but when some of That character appear in the TextCtrl the EVT_TEXT which call function OnTextChange just stop working, all thing back to work properly again when all those character removed.

After hours of debugging and searching for information about unicode bug in wxWindows, I noticed that there’s python exception in SPE’s shell. This bug is nothing but SPE’s coding without aware of non-latin chracter.

I’m going to happily sleep now.

 

Bug

ด้วยเหตุผลบางประการ เวลาพิมพ์ตัวอักษรที่ wxPython ไม่ชอบ เช่น “ฟ” มันจะทำให้ EVT_TEXT เดี๊ยงสนิท ไม่ทำงานอีกเลยจนกว่าจะลบตัวที่มันไม่ชอบออกหมด

ไม่รู้ว่าบั๊กหรือคนใช้โง่เองกันแน่ฟ่ะ