def main(ott, interf): # a = M('plot') # print(isinstance(a,QWidget)) image = np.arange(512**2).reshape((512, 512)) ott.referenceMirror.setPosition( np.array([0.e+00, 0.e+00, 0.e+00, 1.e-07, -4.e-07, 0.e+00])) ott.parabola.setPosition( np.array([0, 0, 9.9999997e-06, 1.0836526e-07, 2.2898718e-09, 0])) ott.parabolaSlider.setPosition(0.75) ott.angleRotator.setPosition(90.) ott.referenceMirrorSlider.setPosition(0.6) oi = OttImages(ott) smap1, smask = oi.ott_smap() cmap = 'viridis' gui = Gui([['hot'], ___, ['viridis'], ___], [M('plot'), M('plot2'), M('plot3'), M('plot4')]) setPlot(gui, image) while True: try: name, event = gui.get(timeout=1) except Empty: setPlot(gui, image**2, cmap) setPlot2(gui, oi, smap1, smask, cmap) setPlot3(gui, oi, cmap) setPlot4(gui, oi, smap1, cmap) continue if name is None: break if name in ['viridis', 'hot']: cmap = name
def RunChatCodder(mainGui): gui = Gui(["ChatCoderImg/Logo.png", ___, ___], [ 'Kill Proof Quantity (16-994):', "__Amount__", _ ], [ 'How many times to ping (random between lower and upper):', "__PingLower__", "__PingUpper__" ], [ 'If you want to ping more than 250, they will be pinged separately. ' 'Fe: 350kp will be pinged in form of 250 and 100 separated. ', _, _ ], [R1("Dhuum"), _, "ChatCoderImg/Dhuum's_Token.png"], [R1("Quadim v1"), _, "ChatCoderImg/Qadim's_Token.png"], [R1("Quadim v2"), _, "ChatCoderImg/Ether_Djinn's_Token.png"], [R1("Unstable Cosmic Essence"), _, "ChatCoderImg/UCE.png"], [R1("Legendary Insight"), _, "ChatCoderImg/LI.png"], [R1("Your Own"), "__Inserted__", ___], [["Press to activate"], ___, ___], [Quit, ___, ___]) gui.Presstoactivate = util.send_kp gui.Amount = "150" gui.PingLower = "2" gui.PingUpper = "4" gui.Inserted = "Or you can provide your own in game link here" gui.run()
def RunAutoJoiner(mainGui): gui = Gui(["AutoJoiner, Created By Magomir", ___, ___], [ "Select if you are in squad with Commander or just in normal party, then just press \"Start\" button.", ___, ___ ], [ "To stop the execution of this script just hold ESC button for a moment", ___, ___ ], ["Join type:", R1("Commander"), R1("Party")], [["Start"], ___, ___], [Quit, ___, ___]) gui.Start = run_joiner gui.run()
def create_party(gui): party = None if gui.Fractal.isChecked(): party = BossConfiguration("CMs + T4") party.add_configuration(dps=2, bs=1, hfb=1, alacrane=1) elif gui.Strike.isChecked(): party = BossConfiguration("All Strike") party.add_configuration(dps=6, bs=1, hfb=2, alacrane=1) try: party.subtract_roles(dps=int(gui.dps), condidps=int(gui.condidps), bs=int(gui.bs), tank=int(gui.tank), druid=int(gui.druid), hfb=int(gui.hfb), alacrane=int(gui.alacrane)) except: gui2 = Gui(["Something went wrong"]) gui2.run() return party_string = party.create_list(gui.kp) activate_gw2() kb.send("Y") sleep(1) if is_key_pressed("esc"): return move_and_click("left", "GroupCreatorImg/lfg.png") if is_key_pressed("esc"): return if gui.Fractal.isChecked(): move_and_click("left", "GroupCreatorImg/fractals.png") if is_key_pressed("esc"): return move_and_click("left", "GroupCreatorImg/t4.png") if is_key_pressed("esc"): return move_and_click("left", "GroupCreatorImg/adv_group.png") if is_key_pressed("esc"): return sleep(0.15) kb.write(party_string) if is_key_pressed("esc"): return elif gui.Strike.isChecked(): move_and_click("left", "GroupCreatorImg/strike_main.png") if is_key_pressed("esc"): return move_and_click("left", "GroupCreatorImg/strike_inner.png") if is_key_pressed("esc"): return move_and_click("left", "GroupCreatorImg/adv_group.png") if is_key_pressed("esc"): return sleep(0.15) kb.write(party_string) if is_key_pressed("esc"): return
def make_cloves_using_refill_button(gui): amount = 0 try: amount = int(gui.Input) except ValueError: Gui(["Wrong input"]).run() return activate_gw2() w_time = 0.05 if is_key_pressed("esc"): return move_and_click("left", "CloverMakerImg/coin.png", clicks=2, wait_time=w_time) if is_key_pressed("esc"): return move_and_click("left", "CloverMakerImg/ecto.png", clicks=2, wait_time=w_time) if is_key_pressed("esc"): return move_and_click("left", "CloverMakerImg/shard.png", clicks=2, wait_time=w_time) if is_key_pressed("esc"): return move_and_click("left", "CloverMakerImg/stone.png", clicks=2, wait_time=w_time) if is_key_pressed("esc"): return move_and_click("left", "CloverMakerImg/forge.png", wait_time=w_time) if is_key_pressed("esc"): return sleep(2) for _ in range(amount - 1): if is_key_pressed("esc"): return move_and_click("left", "CloverMakerImg/accept.png", clicks=1, wait_time=w_time) if is_key_pressed("esc"): return move_and_click("left", "CloverMakerImg/refill.png", clicks=1, wait_time=w_time) if is_key_pressed("esc"): return move_and_click("left", "CloverMakerImg/forge.png", clicks=1, wait_time=w_time) if is_key_pressed("esc"): return sleep(2)
def send_kp(gui): try: ping_times_lower = int(gui.PingLower) ping_times_upper = int(gui.PingUpper) correct_chat_codes = get_correct_chat_code(gui) except ValueError: gui2 = Gui([ "Something went wrong with converting ping times field to integer, " "please check it if it is an integer." ]) gui2.run() return if correct_chat_codes is None: return activate_gw2() for cc in correct_chat_codes: ping_times = np.random.randint(ping_times_lower, ping_times_upper + 1) for _ in range(ping_times): send_procedure(cc) sleep(rand_time(0.18, 0.26))
def RunCloverMaker(mainGui): gui = Gui(["CloverMaker!", ___, ___], [ "Prepare your mystic forge window and make sure you have enough items for clovers in eq", ___, ___ ], [ "How many times do you want to try to create Mystic Clover? 41 is max per 250 P. Stone", "__Input__", _ ], [["Start Refill"], ___, ___], [["Start Old"], ___, ___]) gui.StartRefill = make_cloves_using_refill_button gui.StartOld = make_cloves gui.run()
def get_correct_chat_code(gui): global chat_code try: int_amount = int(gui.Amount) amounts = get_amounts(int_amount) except ValueError: gui2 = Gui([ "Wrong amount of KP. Should be between 1 and 944. Please try again." ]) gui2.run() return if gui.Dhuum.isChecked(): chat_code = dhuum_chat_code elif gui.Quadimv1.isChecked(): chat_code = quadim_v1_chat_code elif gui.Quadimv2.isChecked(): chat_code = quadim_v2_chat_code elif gui.UnstableCosmicEssence.isChecked(): chat_code = unstable_cosmic_essence_chat_code elif gui.LegendaryInsight.isChecked(): chat_code = legendary_insight_chat_code elif gui.YourOwn.isChecked(): chat_code = gui.Inserted else: gui2 = Gui(["You have forgotten to pick what kp do you want to ping"]) gui2.run() return None correct_chat_codes = [] for amount in amounts: correct_chat_codes.append( convert_chat_code_with_amount(chat_code, amount)) return correct_chat_codes
def make_cloves(gui): amount = 0 try: amount = int(gui.Input) except ValueError: Gui(["Wrong input"]).run() return activate_gw2() for _ in range(amount): w_time = 0.05 if is_key_pressed("esc"): break move_and_click("left", "CloverMakerImg/coin.png", clicks=2, wait_time=w_time) if is_key_pressed("esc"): break move_and_click("left", "CloverMakerImg/ecto.png", clicks=2, wait_time=w_time) if is_key_pressed("esc"): break move_and_click("left", "CloverMakerImg/shard.png", clicks=2, wait_time=w_time) if is_key_pressed("esc"): break move_and_click("left", "CloverMakerImg/stone.png", clicks=2, wait_time=w_time) if is_key_pressed("esc"): break move_and_click("left", "CloverMakerImg/forge.png", wait_time=w_time) if is_key_pressed("esc"): break sleep(1.3)
# -*- coding: utf-8 -*- from PySide2.QtCore import Qt from guietta import Gui, _, ___, III, HValueSlider, VValueSlider def do_slider(gui, value): print('Slider value: ', value) import numpy as np slider1 = HValueSlider('hvalue', range(500), unit='Hz') slider2 = HValueSlider('hvalue', range(500), unit='Hz', anchor=Qt.AnchorLeft) slider3 = VValueSlider('hvalue', range(500)) gui = Gui( ['xxx', ['xxx'], 'xxx', slider3], [slider1, ___, ___, III], [slider2, ___, _, III], ) gui.events( [_, _, _, _], [do_slider, _, _, _], [_, _, _, _], ) gui.run()
# -*- coding: utf-8 -*- from guietta import _, ___, Gui, Quit, Exceptions gui = Gui( [ 'Enter numbers:', '__num1__' , '+' , '__num2__', ['Calculate'] ], [ 'Result: -->' , 'result' , ___ , ___ , _ ], [ _ , _ , _ , _ , Quit ], exceptions = Exceptions.POPUP) from PySide2.QtGui import QFont gui.window().setFont(QFont("Helvetica", pointSize = 12, weight=2, italic=True)) gui.widgets['Calculate'].setFont(QFont("Comic Sans MS", weight=5)) with gui.Calculate: gui.result = float(gui.num1) + float(gui.num2) gui.run()
# -*- coding: utf-8 -*- # Demonstrates how to use Gui properties # to connect a handler to a widget's default signal from guietta import _, ___, Gui, Quit, Exceptions gui = Gui(['Enter numbers:', '__num1__', '+', '__num2__', ['Calculate']], ['Result: -->', 'result', ___, ___, _], [_, _, _, _, Quit], exceptions=Exceptions.POPUP) def calc(gui, *args): gui.result = float(gui.num1) + float(gui.num2) # Assign a callable to the button gui.Calculate = calc gui.run()
# -*- coding: utf-8 -*- from guietta import _, ___, Gui, Quit, Exceptions, CB opdict = {'+': '__add__', '-': '__sub__', '*': '__mul__', '/': '__truediv__'} gui = Gui(['Enter numbers:', '__num1__', CB('op', opdict), '__num2__', _], ['Result: -->', 'result', ___, ___, ['Change']], [_, _, _, ['Get'], Quit], exceptions=Exceptions.OFF) with gui.op: name, op = gui.get_selections('op') result = getattr(float(gui.num1), op).__call__(float(gui.num2)) gui.result = result with gui.Get: print('get') print(gui.op) with gui.Change: print('change') opdict = { '^': '__pow__', '==': '__eq__', '>': '__gt__', '//': '__floordiv__' } gui.op = opdict
# To realign in emacs: # C-u align-regexp # as a regexp set this without the quotes: '\(\),' # let default answer '1' for the two question # repeat? yes gui = Gui(['pitch', ___, ___, VSeparator, logo_path], [ HSeparator, ___, ___, III, III ], ['Available drives:', driveChooseComboBox, ['refreshDrivesList'], III, III], ['CD/DVD drive', ['trayOpen'], ['trayClose'], III, III], [HSeparator, ___, ___, III, III], [["genIdFromTime"], ___, 'ortype', III, III], ['Analysis run ID:', '__runID__', ___, III, III], [HSeparator, ___, ___, III, III], [ 'Analysis run control:', ['analysisStart'], ['analysisStop'], III, III ], [HSeparator, ___, ___, III, III], ['Disk type:', 'diskType', ___, III, III], ['Programmed speed:', 'programmedSpeed', ___, III, III], ['Disk capacity:', 'diskCapacity', ___, III, III], ['Sector size:', 'sectorSize', ___, III, III], ['Analysis progress', P('analysisProgress'), ___, III, III], [PG('plot')], title=product_name + " - " + pitch.replace('\n', " "), exceptions=Exceptions.PRINT) labels = { 'pitch': pitch, 'trayOpen': 'Open tray', 'trayClose': 'Close tray', 'genIdFromTime': 'Generate new ID from current time',
from guietta import Gui, M, _, ___, III, VS, Ax import numpy as np def replot(gui, value): with Ax(gui.plot) as ax: ax.set_title('y=sin(x)') t = np.linspace(0, 1+value/10, 500) ax.plot(t, np.sin(t), ".-") gui = Gui( [M('plot'), ___, ___, VS('slider')], [III, III, III, III], [III, III, III, III], [III, III, III, '^^^ Move the slider'], ) gui.events( [_, _, _, replot], [_, _, _, _], [_, _, _, _], ) replot(gui, 1) gui.run()
import numpy as np import pandas as pd import joblib from guietta import _, Gui , Quit gui = Gui( title = 'Bank GUI' ['Enter Values:', "__a__","__b__","__c__","__d__","__e__","__f__","__g__",['Predict']], [' Prediction :' ,'result', _ , _, _,_ , _, _, _ ], [_ ,_ ,_ ,_ , Quit, _ , _, _,_ ] ) algo = joblib.load(r"C:\Users\fahra\OneDrive\Desktop\Bank\bank.pkl") encoder = joblib.load(r'C:\Users\fahra\OneDrive\Desktop\Bank\bank_encoder.pkl') with gui.Predict: new=[[float(gui.a),gui.b,float(gui.c),float(gui.d),float(gui.e),float(gui.f),float(gui.g)]] n = encoder.transform(new) predict = algo.predict(n) if predict == [1]: gui.result = "High chance of customer exiting." else: gui.result = "High chance of customer not exiting." gui.run()
# Does not work because both the module "u" and the function # orbital_speed() in the with block become undefined. import numpy as np import astropy.units as u from astropy.constants import G, M_earth, R_earth from guietta import Gui, ___, HValueSlider def orbital_speed(h): '''h = height over earth surface''' return np.sqrt(G * M_earth / (R_earth + h)) hslider = HValueSlider('h', myrange=range(500, 40000), unit='km') gui = Gui( ['Orbital height:', hslider, ___], ['results', ___, ___], ) with gui.h: info = {} info['Orbital height:'] = gui.h * u.km info['Orbital speed:'] = orbital_speed(gui.h * u.km) info['Orbital length:'] = 2 * np.pi * gui.h * u.km gui.results = info gui.run()
# -*- coding: utf-8 -*- from guietta import B, E, _, Gui, Quit # Use *args to accept multiple signals # with different arguments. def do_eval(gui, *args): print(gui.foo) gui.bar = eval(gui.foo) gui = Gui(['Enter expression:', E('expr'), B('Eval!')], ['Result:', 'result', _], [_, _, Quit]) gui.events( [_, do_eval, do_eval], [_, _, _], [_, _, _], ) gui.rename( [_, 'foo', _], [_, 'bar', _], [_, _, _], ) gui.run() # GUI widgets are available after window closing,
def myeval(gui): gui.result = eval(gui.expr) def reset(gui): global counter counter = 0 def stop(gui): gui.timer_stop() def start(gui): gui.timer_start(regular_update, interval=0.1) gui = Gui(['Enter expression:', '__expr__', ['Eval!']], ['Result:', 'result', _], [['Start'], ['Stop'], ['Reset']], ['counter', _, Quit]) gui.events( [_, myeval, myeval], [_, _, _], [start, stop, reset], [_, _, _], ) start(gui) gui.run()
# -*- coding: utf-8 -*- import os.path from guietta import Gui, _ # Labels and button automatically load images if the filename is valid, # otherwise it will appear as text. # # Widget names are set to the image name without extension. gui = Gui([_, 'up.png', _], [['left.png'], _, ['right.png']], [_, 'down.png', _], images_dir=os.path.dirname(__file__)) while True: name, event = gui.get() if name == 'left': print('Clicked left!') if name == 'right': print('Clicked right!') if name == None: break
# -*- coding: utf-8 -*- from guietta import _, ___, Gui, Quit, Exceptions gui = Gui(['Enter numbers:', '__num1__', '+', '__num2__', ['Calculate']], ['Result: -->', 'result', ___, ___, _], [_, _, _, _, Quit], exceptions=Exceptions.POPUP, font='Comic Sans MS') gui.fonts( [_, _, _, _, 'Arial'], [('Helvetica', 12, 2), _, _, _, _], [_, _, _, _, _], ) with gui.Calculate: gui.result = float(gui.num1) + float(gui.num2) gui.run()
# -*- coding: utf-8 -*- from guietta import Gui gui1 = Gui(['a', 'b', ['C']]) gui2 = Gui(['a', 'd', ['E']]) gui1.a = 'foo' gui2.a = 'bar' gui1.show() gui2.show() gui1._app.exec()
# -*- coding: utf-8 -*- from guietta import B, C, E, _, Gui, Quit def do_eval(gui, *args): gui.result = eval(gui.expr) def checkbox(gui, state): print('Checkbox state is', state) gui = Gui(['Enter expression:', E('expr'), B('Eval!')], ['Result:', 'result', _], [C('test'), _, Quit]) gui.events( [_, do_eval, do_eval], [_, _, _], [checkbox, _, _], ) gui.run() # GUI widgets are available after window closing, print(gui.result)
''' Generate Electricity bill using simple gui ''' from guietta import _, Gui, Quit # Defining Gui for the program gui = Gui(["Enter the units of electricity consumed: ", '__units__'], [['Generate'], Quit], ["-----------------Bill-------------------", _], ["No. of units consumed: ", 'units_consumed'], ["Base unit: ", 'base_unit'], ["Base price: ", 'base_price'], ["No. of units above base unit: ", 'extra_units'], ["Price per extra units: ", 'extra_units_price'], ["-------------------------------------------------", _], ["Total amount to pay: ", 'total']) # Function for the button generate def calculate_bill(gui): if (int(gui.units) < 150): gui.unit_consumed = float(gui.units) gui.base_unit = 0.0 gui.base_price = 3 gui.extra_units = 0 gui.extra_units_price = 0 gui.total = float(gui.units) * float(gui.base_price) elif ((float(gui.units) > 151) & (float(gui.units) < 300)): gui.units_consumed = float(gui.units) gui.base_unit = 150 gui.base_price = 100
# -*- coding: utf-8 -*- from guietta import _, ___, Gui, Quit, HS gui = Gui(['Enter numbers:', '__num1__', '+', '__num2__', ['Calculate']], ['Result: -->', 'result', ___, ___, _], [HS('slider'), ___, ___, '__value__', Quit]) while True: name, event = gui.get() if name == 'Calculate': try: gui.result = float(gui.num1) + float(gui.num2) except Exception as e: gui.result = 'Error: ' + str(e) # Original widget still accessible via widgets[] print(gui.widgets['result'].text()) if name == 'slider': gui.value = gui.slider if name == 'value': gui.slider = gui.value elif name is None: break
# -*- coding: utf-8 -*- from guietta import _, ___, Gui, Quit, Exceptions gui = Gui( ['Enter numbers:', '__num1__', '+', '__num2__', (['Calculate it'], 'foo')], ['Result: -->', 'result', ___, ___, _], [_, _, _, _, Quit], exceptions=Exceptions.POPUP) with gui.foo: gui.result = float(gui.num1) + float(gui.num2) gui.run()
except ImportError: from PyQt5.QtWidgets import QDial, QLCDNumber, QTableWidget from PyQt5.QtWidgets import QTableWidgetItem, QHeaderView gui = Gui( ['<center>A big GUI with all of Guietta' 's widgets</center>'], ['<center>Move the dial!</center>'], [HSeparator], ['Label', 'imagelabel.jpeg', L('another label'), VS('slider1')], [_, ['button'], B('another button'), III], ['__edit__', E('an edit box'), _, VSeparator], [R1('rad1'), R1('rad2'), R1('rad3'), III], [R2('rad4'), R2('rad5'), R2('rad6'), III], [C('ck1'), C('ck2'), C('ck3'), III], [Quit, Ok, Cancel, III], [Yes, No, _, III], [HS('slider2'), ___, ___, _], [(QDial, 'dial'), (QLCDNumber, 'lcd'), ___, _], [(QTableWidget, 'tab1'), ___, ___, ___], [III, III, III, III], [III, III, III, III], [P('progbar'), (QLCDNumber, 'lcd2'), _, _], [L('l1'), L('l2'), L('l3'), L('l4')], ) gui.window().setGeometry(100, 100, 600, 900) # posx, posy, w, h gui.widgets['dial'].setNotchesVisible(True)
from guietta import _, Gui, Quit gui = Gui(['Enter numbers:', '__a__', '+', '__b__', ['Calculate']], ['Result: -->', 'result', _, _, ['Reset']], [_, _, _, _, Quit]) with gui.Calculate: gui.result = float(gui.a) + float(gui.b) with gui.Reset: gui.a = 0 gui.b = 0 gui.result = 'result' gui.run()
# -*- coding: utf-8 -*- from guietta import B, E, _, Gui, Quit, QSlider, Qt def do_eval(gui, *args): gui.result = eval(gui.expr) def do_slider(gui, state): gui.result = '%d' % state s = QSlider(Qt.Horizontal) gui = Gui(['Enter expression:', E('expr'), B('Eval!')], ['Result:', 'result', _], [(s, 'myslider'), _, Quit]) gui.events( [_, do_eval, do_eval], [_, _, _], [do_slider, _, _], ) gui.run() # GUI widgets are available after window closing, print(gui.result)
# -*- coding: utf-8 -*- from guietta import Gui, LB, _, III def listbox(gui, text): print(text) def test(gui, *args): print(gui.listbox) gui = Gui([LB('listbox')], [III], [III], [['Test']]) gui.events( [listbox], [_], [_], [test], ) gui.widgets['listbox'].setSelectionMode( gui.widgets['listbox'].ExtendedSelection) gui.listbox = ['a', 'b', 'c', 'd'] gui.run()