You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# -*- coding: gbk -*-
import wx
import os
class Panel ( wx . Panel ) :
def __init__ ( self , parent ) :
wx . Panel . __init__ ( self , parent )
self . my_text = wx . TextCtrl ( self , style = wx . TE_MULTILINE )
btn = wx . Button ( self , label = ' <EFBFBD> <EFBFBD> txtС ˵<EFBFBD> ļ<EFBFBD> ' )
btn . Bind ( wx . EVT_BUTTON , self . Open )
sizer = wx . BoxSizer ( wx . VERTICAL )
sizer . Add ( self . my_text , 1 , wx . ALL | wx . EXPAND )
sizer . Add ( btn , 0 , wx . ALL | wx . CENTER , 5 )
self . SetSizer ( sizer )
def Open ( self , event ) :
wildcard = " TXT files (*.txt)|*.txt "
dialog = wx . FileDialog ( self , " <EFBFBD> <EFBFBD> txtС ˵<EFBFBD> ļ<EFBFBD> " , wildcard = wildcard ,
style = wx . FD_OPEN | wx . FD_FILE_MUST_EXIST )
if dialog . ShowModal ( ) == wx . ID_CANCEL :
return
path = dialog . GetPath ( )
if os . path . exists ( path ) :
with open ( path ) as fobj :
for line in fobj :
self . my_text . WriteText ( line )
class Frame ( wx . Frame ) :
def __init__ ( self ) :
wx . Frame . __init__ ( self , None , title = ' С ˵<EFBFBD> Ķ<EFBFBD> <EFBFBD> <EFBFBD> ' )
panel = Panel ( self )
self . Show ( )
if __name__ == ' __main__ ' :
app = wx . App ( False )
frame = Frame ( )
frame . Show ( )
app . MainLoop ( )