PyQt5'te Arayüz Gelmiyor

Arkadaslar merhaba, kodu caliştirdiğimda arayüz gelmeden direk işlemlere basliyor. Arayüzün gelmesini, start/stop demeden işlem yapmasını istemiyorum. Nerede hata yapiyorum bir türlü çözemedim. Kodu düzenleyip, kopyalayabilirmisiniz.

import sys
import time
import pyautogui
import keyword
import win32api,win32con
from PyQt5.QtWidgets import QApplication,QVBoxLayout,QHBoxLayout,QCheckBox,QPushButton,QMainWindow,QWidget,QLineEdit,QLabel,QFileDialog
from PyQt5.QtGui import QIcon,QFont

class mainWindow(QWidget):
    def __init__(self):
        super().__init__()
        self.setGeometry(1200,200,400,200)
        self.setWindowTitle("DENEME")
        self.setWindowIcon(QIcon("anvil.jpg"))
        self.contents()
        self.isRunning = False

        self.show()


    def contents(self):
        self.btnStart = QPushButton(self)
        self.btnStart.setText("START")
        self.btnStart.setStyleSheet("background-color : green")
        self.btnStart.setFont(QFont("arial", 12, QFont.Bold))

        self.btnStop = QPushButton(self)
        self.btnStop.setText("STOP")
        self.btnStop.setStyleSheet("background-color : red")
        self.btnStop.setFont(QFont("arial", 12, QFont.Bold))



        self.btnStart.move(10,10)
        self.btnStop.move(100,10)


        self.btnStart.clicked.connect(self.start)
        self.btnStop.clicked.connect(self.stop)


        self.lblMesaj = QLabel("Upgrade Scroll Kagidini Inventoryden 28.Slota\nYani Sağ En Alt Slota Koyun.", self)
        self.lblMesaj.setFont(QFont("arial", 12, QFont.Bold))
        self.lblMesaj.move(45, 75)

        self.lblNot = QLabel("Not:", self)
        self.lblNot.setFont(QFont("arial", 12, QFont.Bold))
        self.lblNot.move(10, 75)
        self.lblNot.setStyleSheet("background-color: turquoise")

    def start(self):
        for i in range(26):
            if not self.isRunning:
                self.start()
                print("Upgrade Başlatıldı..")

    def stop(self):
        def stop(self):
            self.isRunning = True
            print("Upgrade Durduruldu..")

def click(x, y):
    win32api.SetCursorPos((x, y))
    time.sleep(0.1)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
    time.sleep(0.1)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)

def rightclick(x, y):
    win32api.SetCursorPos((x, y))
    time.sleep(0.1)
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, x, y, 0, 0)
    time.sleep(0.1)
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, x, y, 0, 0)

def anvil():

    click(536,382)      #anvile sol tıklayıp seçme
    time.sleep(0.1)
    rightclick(536,382)   #anvile sag tıklayıp açma
    time.sleep(0.1)
    click(520,395)         #upgrade item butonuna tıklama
    time.sleep(0.1)



def slot(slot1x, slot1y):
    rightclick(slot1x,slot1y)  # 1.slot 1.kutuya sağ tıklama
    time.sleep(0.2)
    rightclick(969, 610)  # upgrade scroll'a sag tıklama
    time.sleep(0.2)
    click(751, 357)  # confirm butonu 1
    time.sleep(0.2)
    click(739, 481)  # confirm butonu 2
    time.sleep(1)
    click(1002, 61)  # pencereyi kapatma(x)


slot1x = 688
slot1y = 466
for i in range(7):
    anvil()
    slot(slot1x,slot1y)
    slot1x += 50

slot1x = 688
slot1y = 515
for i in range(7):
    anvil()
    slot(slot1x, slot1y)
    slot1x += 50

slot1x = 688
slot1y = 566
for i in range(7):
    anvil()
    slot(slot1x,slot1y)
    slot1x += 50

slot1x = 688
slot1y = 615
for i in range(5):
    anvil()
    slot(slot1x,slot1y)
    slot1x += 50




def windows():
    app = QApplication(sys.argv)
    win = mainWindow()
    sys.exit(app.exec_())

windows()

  1. satır ile 125. satır arasındaki kodlar fonksiyonun içinde değil dolayısıyla arayüz gelmeden önce çalışıyorlar onları fonksiyonun içine alırsanız çözüleceğini umuyorum.
1 Beğeni
import sys
import time
import pyautogui
import keyword
import win32api
import win32con
import threading
from PyQt5.QtWidgets import QApplication, QVBoxLayout, QHBoxLayout, QCheckBox, QPushButton, QMainWindow, QWidget, QLineEdit, QLabel, QFileDialog
from PyQt5.QtGui import QIcon, QFont
#script.
class mainWindow(QWidget):
    def __init__(self):
        super().__init__()
        self.setGeometry(1200, 200, 400, 200)
        self.setWindowTitle(" ankara ")
        self.setWindowIcon(QIcon("anvil.jpg"))
        self.contents()
        self.isRunning = False

        self.show()

    def contents(self):
        self.btnStart = QPushButton(self)
        self.btnStart.setText("START")
        self.btnStart.setStyleSheet("background-color : green")
        self.btnStart.setFont(QFont("arial", 12, QFont.Bold))

        self.btnStop = QPushButton(self)
        self.btnStop.setText("STOP")
        self.btnStop.setStyleSheet("background-color : red")
        self.btnStop.setFont(QFont("arial", 12, QFont.Bold))

        self.btnStart.move(10, 10)
        self.btnStop.move(100, 10)

        self.btnStart.clicked.connect(self.start)
        self.btnStop.clicked.connect(self.stop)

        self.lblMesaj = QLabel("Upgrade Scroll Kagidini Inventoryden 28.Slota\nYani Sağ En Alt Slota Koyun.", self)
        self.lblMesaj.setFont(QFont("arial", 12, QFont.Bold))
        self.lblMesaj.move(45, 75)

        self.lblNot = QLabel("Not:", self)
        self.lblNot.setFont(QFont("arial", 12, QFont.Bold))
        self.lblNot.move(10, 75)
        self.lblNot.setStyleSheet("background-color: turquoise")

    def start(self):
        if not self.isRunning:
            self.isRunning = True
            self.worker_thread = threading.Thread(target=self.process)
            self.worker_thread.start()

    def stop(self):
        self.isRunning = False

    def process(self):
        slot1x = 688
        slot1y = 466
        for i in range(7):
            if not self.isRunning:
                break
            anvil()
            slot(slot1x, slot1y)
            slot1x += 50

        slot1x = 688
        slot1y = 515
        for i in range(7):
            if not self.isRunning:
                break
            anvil()
            slot(slot1x, slot1y)
            slot1x += 50

        slot1x = 688
        slot1y = 566
        for i in range(7):
            if not self.isRunning:
                break
            anvil()
            slot(slot1x, slot1y)
            slot1x += 50

        slot1x = 688
        slot1y = 615
        for i in range(5):
            if not self.isRunning:
                break
            anvil()
            slot(slot1x, slot1y)
            slot1x += 50

        self.isRunning = False

def click(x, y):
    win32api.SetCursorPos((x, y))
    time.sleep(0.1)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
    time.sleep(0.1)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)

def rightclick(x, y):
    win32api.SetCursorPos((x, y))
    time.sleep(0.1)
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, x, y, 0, 0)
    time.sleep(0.1)
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, x, y, 0, 0)

def anvil():
    click(536, 382)  
    time.sleep(0.1)
    rightclick(536, 382)  
    time.sleep(0.1)
    click(520, 395)  
    time.sleep(0.1)

def slot(slot1x, slot1y):
    rightclick(slot1x, slot1y)  
    time.sleep(0.2)
    rightclick(969, 610)  
    time.sleep(0.2)
    click(751, 357)  
    time.sleep(0.2)
    click(739, 481)  
    time.sleep(1)
    click(1002, 61)  

def windows():
    app = QApplication(sys.argv)
    win = mainWindow()
    sys.exit(app.exec_())

windows()

şuan work , merak ettiğim konu şu bu ne işe yarıyor metin2 +9 basma botu gibi bir şey mi yardımcı olabilirim

1 Beğeni

Tesekkur ederim hocam. Eve gecince inceleyecegim.

Tesekkur ederim hocam. Knight’la ilgili reis. Oyunu oynamiyorum, bir kazanc saglamak icinde cabalamiyorum. Sadece kendimi gelistirmek icin bir yol üzerinde gidiyorum.

Kolay gelsin bir şey olursa dm de atabilirsiniz

Tesekkur ederim reis. Sorunsuz bir sekilde calisti.

1 Beğeni