# -*- coding:utf-8 -*-
import wx # 导入wxPython
import chatApi
class MyFrame(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, '论文降重', size=(800,660))
# 创建面板
panel = wx.Panel(self)
# 创建“确定”和“取消”按钮, 并绑定事件
self.bt_confirm = wx.Button(panel, label='开始降重')
self.bt_confirm.Bind(wx.EVT_BUTTON, self.OnclickSubmit)
self.bt_cancel = wx.Button(panel, label='清空')
self.bt_cancel.Bind(wx.EVT_BUTTON, self.OnclickCancel)
#创建关于按钮,并绑定事件
self.bt_about = wx.Button(panel, label='关于')
self.bt_about.Bind(wx.EVT_BUTTON, self.OnclickAbout)
# 创建文本,左对齐
self.title = wx.StaticText(panel, label="在线论文降重")
self.label_user = wx.StaticText(panel, label="原论文")
self.text_user = wx.TextCtrl(panel,pos = (5,39),size = (100,250),style = wx.TE_MULTILINE)
self.label_rebot = wx.StaticText(panel, label="降重后")
self.text_rb = wx.TextCtrl(panel,pos = (5,39),size = (100,240),style = wx.TE_MULTILINE)
self.text_rb.write('在线论文降重,粘贴论文文字至上方!')
# 添加容器,容器中控件按横向并排排列
hsizer_user = wx.BoxSizer(wx.HORIZONTAL)
hsizer_user.Add(self.label_user, proportion=0, flag=wx.ALL, border=5)
hsizer_user.Add(self.text_user, proportion=1, flag=wx.ALL, border=5)
hsizer_rb = wx.BoxSizer(wx.HORIZONTAL)
hsizer_rb.Add(self.label_rebot, proportion=0, flag=wx.ALL, border=5)
hsizer_rb.Add(self.text_rb, proportion=1, flag=wx.ALL, border=5)
hsizer_button = wx.BoxSizer(wx.HORIZONTAL)
hsizer_button.Add(self.bt_confirm, proportion=0, flag=wx.ALIGN_CENTER, border=2)
hsizer_button.Add(self.bt_cancel, proportion=0, flag=wx.ALIGN_CENTER, border=2)
# hsizer_button.Add(self.bt_about, property=0, flag=wx.ALIGN_CENTER,border=2)
# 添加容器,容器中控件按纵向并排排列
vsizer_all = wx.BoxSizer(wx.VERTICAL)
vsizer_all.Add(self.title, proportion=0, flag=wx.BOTTOM | wx.TOP | wx.ALIGN_CENTER,
border=15)
vsizer_all.Add(hsizer_user, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=45)
vsizer_all.Add(hsizer_rb, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=45)
vsizer_all.Add(hsizer_button, proportion=0, flag=wx.ALIGN_CENTER | wx.TOP, border=10)
panel.SetSizer(vsizer_all)
def OnclickSubmit(self, event):
""" 点击确定按钮,执行方法 """
message = ""
EngNews = self.text_user.GetValue()
ChiNews=self.text_rb.GetValue()
if EngNews == "":
message = '请输入你要降重的文字!'
wx.MessageBox(message,'Warning',wx.OK| wx.ICON_WARNING)
if EngNews!="" :
self.text_rb.SetValue("")
self.text_rb.write(chatApi.start(EngNews))
def OnclickCancel(self, event): # 没有event点击取消会报错
""" 点击清空按钮,执行方法 """
self.text_user.SetValue("")
self.text_rb.SetValue("")
def OnclickAbout(self,event):
wx.MessageBox('在线论文降重 by 小何','关于作者',wx.OK)
if __name__ == '__main__':
app = wx.App() # 初始化应用
frame = MyFrame(parent=None, id=1) # 实例MyFrame类,并传递参数
frame.Show() # 显示窗口
app.MainLoop() # 调用MainLoop()主循环方法
chatApi.py
# -*- coding:utf-8 -*-
import requests
import json
import random
def getStr():
code = ''
for i in range(13):
ran1 = str(random.randint(0, 9)) # 0~9之间的数字
ran2 = chr(random.randint(65, 90)) # a~z的字母
ran3 = chr(random.randint(97, 122)) # A~Z的字母
r = random.choice([ran1, ran2, ran3]) # 从a~z、A~Z、0-9中选出一个字符
code += r # 循环取出4个
return code
def start(msg):
s=getStr()
url="https://testwww.paperyy.com/api/v1/reduce/reduce-sentence/other/"+str(s)
# print(getStr())
# start(msg)
效果
阅读全文