招き猫 GUIでBOT起動

BitcoinBot「招き猫」目次に戻る

BOTのリモートコントロールをしたい

GoogleのChromeRemoteDesktopをご存知だろうか。

家のpcでBOTをテスト稼働しているのだが、当然リモートで止めたい。

GoogleのChromeRemoteDesktopというサーバー&クライアントアプリが有る。

pcに画面サーバー化ソフトを入れて、携帯にアプリを入れて、ほとんど設定らしいもののもなく、携帯から家のpcが操作できる。さすがgoogleすごすぎる。

しかし、pythonの無限loopを止めるのは[^c]コントロール+c なのだが、携帯に[^c]はない。

では、ストップボタンを設置しようと思ったのが事の始め。

結論として未だ実現できていない。

だが、起動ボタンは簡単に設置できた。

python のtkinter

pythonにはtkinter というお手軽にグラフィカルなインターフェースを作れるモジュールがある。

適当なWEB見ながらのコピペチョロチョロで俺のような初心者様でも数時間で作れてしまう。

両方うちの猫。左がソラ、右がレオ。可愛いので、負けても「しゃーない」ってなるわ笑

写真を2枚用意して↓がコード

#!/usr/bin/python3
# Author:      leococo
# Created:     11/02/2020
#thanks https://python.keicode.com/advanced/tkinter-widget-button.php
from tkinter import *
from tkinter import ttk
import os

#----snip----------------------------------------
root = Tk()
root.title("bitcoin 招き猫様 降臨")#rootウィンドウのタイトルを変える
s = StringVar()
# Frame as Widget Container
frame1 = ttk.Frame(root,padding=5)
frame1.grid()

# Button 1 --------------------------------------
def run_bot():
    button1.state(['pressed'])
    button2.state(['!pressed'])
    s.set("幸せを呼ぶ 招き猫様 召喚致します ")
    #os.system("python manekineko.py")

icon1 = PhotoImage(file='nekosama.png')
button1 = ttk.Button(
    frame1,
    image=icon1,
    text='幸せの招き猫',
    compound=TOP,
    command=run_bot)
button1.grid(row=1,column=1)

# Button 2 ---------------------------------------
def run_plot():
    button1.state(['!pressed'])
    button2.state(['pressed'])
    s.set("幸せを数えてみましょう")
    #os.system("python BF_position_plot2.py")

icon2 = PhotoImage(file='yatteranne.png')
button2 = ttk.Button(
    frame1,
    image=icon2,
    text='グラフ書き書き',
    compound=TOP,
    command=run_plot)

button2.grid(row=1,column=2)

# Label 1 -------------------------------------------
label1 = ttk.Label(
    frame1,
    foreground='red',#ff0000',
    background='yellow',
    textvariable=s)

label1.grid(row=2,column=1,columnspan=2)
#------------------------------------------------------

if __name__ == "__main__":
     root.mainloop()

 

BitcoinBot「招き猫」目次に戻る

タイトルとURLをコピーしました