wxpython透明记事本

QQ群:476842922(欢迎加群讨论学习
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 27 23:07:01 2018

@author: Administrator
"""
import wx

class MyFrame2 ( wx.Frame ):

	response = ""
	
	def __init__( self, parent ):
		wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
		
		self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
		
		self.m_menubar3 = wx.MenuBar( 0 )
		self.m_menu6 = wx.Menu()
		self.m_menuItem3 = wx.MenuItem( self.m_menu6, wx.ID_ANY, u"Open", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu6.AppendItem( self.m_menuItem3 )
		
		self.m_menuItem4 = wx.MenuItem( self.m_menu6, wx.ID_ANY, u"Save", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu6.AppendItem( self.m_menuItem4 )
		
		self.m_menubar3.Append( self.m_menu6, u"File" ) 
		
		self.SetMenuBar( self.m_menubar3 )
		
		bSizer2 = wx.BoxSizer( wx.VERTICAL )
		
		self.m_textCtrl2 = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 600,600 ), 0)
		self.m_textCtrl2.SetBackgroundColour('Black')
		self.m_textCtrl2.SetForegroundColour('Green')
		self.SetTransparent(200)
		bSizer2.Add( self.m_textCtrl2, 0, wx.ALL, 5 )
		
		
		self.SetSizer( bSizer2 )
		self.Layout()
		
		self.Centre( wx.BOTH )
		
		# Connect Events
		self.Bind( wx.EVT_MENU, self.open, id = self.m_menuItem3.GetId() )
		self.Bind( wx.EVT_MENU, self.save, id = self.m_menuItem4.GetId() )
	
	def __del__( self ):
		pass
	
	
	# Virtual event handlers, overide them in your derived class
	def open( self, event ):
		dlg = wx.TextEntryDialog(None, "Input open file name",'Open File', 'Cary Grant')
		result = dlg.ShowModal()
		if dlg.ShowModal() == wx.ID_OK:
		    response = dlg.GetValue()
		    file=open(response)
		    self.m_textCtrl2.SetValue(file.read())
		    file.close	

	def save( self, event ):
		file=open("temFile.txt",'w')
		file.write(self.m_textCtrl2.GetValue())
		file.close()

def main():
    app = wx.App()
    ex = MyFrame2(None)
    ex.Show()
    app.MainLoop()


if __name__ == '__main__':
    main()   

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值