Skip to content

Commit

Permalink
更新send_text_ui例子
Browse files Browse the repository at this point in the history
  • Loading branch information
smallevilbeast committed Sep 23, 2022
1 parent 89ea755 commit 734eab0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ except KeyboardInterrupt:
# -*- coding: utf8 -*-
import xcgui
import ntchat
from xcgui import XApp, XWindow
from xcgui import XApp, XWindow, RunUiThread


class NtChatWindow(XWindow):
Expand All @@ -171,6 +171,8 @@ class NtChatWindow(XWindow):
def on_btn_open_clicked(self, sender, _):
self.wechat_instance = ntchat.WeChat()
self.wechat_instance.open(smart=True)

# 监听所有通知消息
self.wechat_instance.on(ntchat.MT_ALL, self.on_recv_message)

def on_btn_send_clicked(self, sender, _):
Expand All @@ -182,6 +184,7 @@ class NtChatWindow(XWindow):
else:
self.wechat_instance.send_text(self.edit_wxid.getText(), self.edit_content.getText())

@RunUiThread()
def on_recv_message(self, wechat, message):
text = self.edit_log.getText()
text += "\n"
Expand Down
3 changes: 2 additions & 1 deletion examples/send_text_ui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import xcgui
import ntchat
from xcgui import XApp, XWindow
from xcgui import XApp, XWindow, RunUiThread


class NtChatWindow(XWindow):
Expand Down Expand Up @@ -38,6 +38,7 @@ def on_btn_send_clicked(self, sender, _):
else:
self.wechat_instance.send_text(self.edit_wxid.getText(), self.edit_content.getText())

@RunUiThread()
def on_recv_message(self, wechat, message):
text = self.edit_log.getText()
text += "\n"
Expand Down
2 changes: 0 additions & 2 deletions fastapi_example/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,5 @@ async def send_gif(model: models.SendPatReqModel):
return response_json(1, data)




if __name__ == '__main__':
uvicorn.run(app=app, host='0.0.0.0', port=8000)

0 comments on commit 734eab0

Please sign in to comment.