python编译器无法运行input_Py 文件双击运行闪退, IDLE 运行正常 (绝对不是没加 input 的问题)...

from PySide2.QtWidgets import QApplication,QMainWindow,QPushButton,QPlainTextEdit,QMessageBox

from PySide2.QtUiTools import QUiLoader

from PySide2.QtCore import QFile

Rmdiction1 = {'a':'01','b':'02','c':'03','d':'04','e':'05','f':'10','g':'11','h':'12','i':'13','j':'14','k':'15','l':'20','m':'21','n':'22','o':'23','p':'24','q':'25','r':'30','s':'31','t':'32','u':'33','v':'34','w':'35','x':'40','y':'41','z':'42',' ':'43',',':'44','.':'45',':':'50',';':'51','<':'52','>':'53','?':'54','/':'55','[':'0001',']':'0010','{':'0100','}':'1000','-':'0011','':'0111','~':'1111','!':'0101','@':'0110','#':'1001','$':'1011','%':'1010','^':'1100','&':'1101','*':'1111','(':'60',')':'61','=':'62','+':'63','|':'64','`':'65','0':'70','1':'71','2':'72','3':'73','4':'74','5':'75','6':'80','7':'81','8':'82','9':'83','\':'84',''':'85','"':'90'}

Rmdiction = {value:key for key,value in Rmdiction1.items()}

def decode(x):

for i in Rmdiction:

if i == x:

print(Rmdiction[i])

return Rmdiction[i]

def encode(x1):

for i1 in Rmdiction1:

if i1 == x1:

print(Rmdiction1[i1])

return Rmdiction1[i1]

class Codec:

def _init(self):

# 从文件中加载UI定义

qfile_stats = QFile(r'C:\Users\Administrator\Desktop\jsr\程序及数据\ui文件\R编解码.ui')

qfile_stats.open(QFile.ReadOnly)

qfile_stats.close()

# 从 UI 定义中动态 创建一个相应的窗口对象

# 注意:里面的控件对象也成为窗口对象的属性了

# 比如 self.ui.button , self.ui.textEdit

self.ui = QUiLoader().load(qfile_stats)

self.ui.button.clicked.connect(self.coding)

self.ui.pushButton.clicked.connect(self.decoding)

self.ui.pushButton_2.clicked.connect(self.PUSH_BUTTON2)

self.ui.pushButton_3.clicked.connect(self.PUSH_BUTTON3)

def coding(self):

replied = self.ui.textedit.toPlainText()

ip = self.ui.textedit1.toPlainText()

message1 = open(replied,'r')

message2 = message1.read()

i3 = 0

receivelist1 = []

Message = message2.lower()

MESSAGE = Message.replace('\n','')

while i3 < len(MESSAGE):

a1 = encode(MESSAGE[i3])

receivelist1.append(a1)

i3 += 1

if i3 == len(MESSAGE):

orderedlist = '\n'.join(receivelist1)

f = open(ip,'w+')

f.writelines(orderedlist)

f.close()

QMessageBox.about(self.ui,'','编码成功')

def decoding(self):

replied = self.ui.textedit.toPlainText()

ip = self.ui.textedit1.toPlainText()

Filehandle = open(replied,'r')

n = Filehandle.read()

Filehandle.close()

v = n.split('\n')

i2 = 0

receivelist = []

while i2 < len(v):

a = decode(v[i2])

receivelist.append(a)

i2 += 1

if i2 == len(v):

orderedlist1 = ''.join(receivelist)

f = open(ip,'w+')

f.writelines(orderedlist1)

f.close()

QMessageBox.about(self.ui,'','解码成功')

def PUSH_BUTTON2(self):

version = '''**********使用说明**********

此程序可以将英文进行编码操作,对R码数字进行解码操作。

本程序不支持不使用英文字母的语言,请确保文件的内容正确。

以及关于文件的路径问题:

例如Jenny想要进行编码或解码的文件在桌面上,

而且她使用的是widowsXP系统,那么如果文件的名字为01.txt的话,

01.txt的路径就为C:\Documents and Settings\Administrator\桌面\01.txt

(特别提醒:目前只支持txt文件,即记事本文件)'''

QMessageBox.about(self.ui,'使用说明',version)

def PUSH_BUTTON3(self):

instructions = '''

R编解码版本:1.2 修改时间:2020.2.25 19:44:31.69

相比1.1版本,此次更新修复、添加了

1.增强了图形用户界面

2.删除了编解码时会逐一打印的值对的功能

3.修复了编解码时文件里字符串空行造成编解码操作出错的情况'''

QMessageBox.about(self.ui,'版本介绍',instructions)

app = QApplication([])

codec =Codec()

codec.ui.show()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值