Ok, so I still have gui (In Java) and a program (In Python). I want the button in gui to be pressed in order to send the outputs to the python program and run it. Then I want the gui program to display python print commands in the text box on the right.
So my question is: is this possible and how can I make it work?
GUI
import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class dogedice extends JFrame implements ActionListener { private static final long serialVersionUID = 1L; private JPanel contentPane; private JTextField textField; private JComboBox combo; public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { dogedice frame = new dogedice(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } public dogedice() { setTitle("DogeDice Bot"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JPanel panel = new JPanel(); contentPane.add(panel, BorderLayout.WEST); GridBagLayout gbl_panel = new GridBagLayout(); gbl_panel.columnWidths = new int[]{0, 0}; gbl_panel.rowHeights = new int[]{0, 0}; gbl_panel.columnWeights = new double[]{0.0, 1.0}; gbl_panel.rowWeights = new double[]{0.0, Double.MIN_VALUE}; panel.setLayout(gbl_panel);
Python program:
import random import time username = gtk.entry.get_text("usernameimput") password = gtk.entry.get_text("passwordimput") odds = gtk.entry.get_text("oddsimput") RollBelow = odds RollAbove = 100 - odds - 0.0001 currency = gtk.entry.get_text("currencyimput") LowerStopLimit = gtk.entry.get_text("minimumimput") Low = "0" High = "1" startbet = gtk.entry.get_text("startingbetimput") multiplyer = gtk.entry.get_text("multiplierimput") maxbet = gtk.entry.get_text("maxbetimput") bet = startbet key = -1 print "Logging in..." while key == -1: try: key = peerbetapi.__login(username, password) except: key = -1 if key == -1: print "Error logging in. Retrying..." print "Logged in..." result = peerbetapi.__roll_dice(key, High, RollAbove, currency, bet, random.randint(1,999999999)) startbalance = float(result["user_balance"]) Stopbot = False while Stopbot == False: try: if float(result["game_won"]) == 0: # we lost so multiply the bet bet = "%0.8f" % (float(bet) * float(multiplyer)) if float(bet) > float(maxbet): print "*** MAX BET REACHED RESETING ***" bet = startbet print "Bet: " + bet print "Profit: %0.8f" % (float(result["user_balance"]) - startbalance) else: # we won so reset the bet to the start bet bet = startbet print "Bet: " + bet print "Profit: %0.8f" % (float(result["user_balance"]) - startbalance) if float(result["dice_roll"]) >= 50: result = peerbetapi.__roll_dice(key, Low, RollBelow, currency, bet, random.randint(1,999999999)) else: result = peerbetapi.__roll_dice(key, High, RollAbove, currency, bet, random.randint(1,999999999)) print "Balance: %3.4f" % float(result["user_balance"]) + " Rolled: %06.4f" % float(result["dice_roll"]) + " Target: " + str(result["dice_target"]) + " Won: " + str(result["game_won"]) if float(result["user_balance"]) <= float(LowerStopLimit): Stopbot = True except: print "Error: Last multiplyer %0.4f" % float(bet) time.sleep(30) #time.sleep(1)
java python
michaeladair
source share