pyNetLogo
pyNetLogo copied to clipboard
Using PyQT5 to start NetLogo
Hi,
I am developing a GUI app using PyQt5 to start NetLogo 3D using pyNetLogo. I simply add a button in the UI and bing the click event to its function to call NetLogo. However, the opened 3D view showed just like this (the world size is reduced as the below image shown):

My program is below:
import PyQt5
import pyNetLogo
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow
from test1 import Ui_MainWindow
import ctypes
import sys
class NetLogoWin(QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(NetLogoWin, self).__init__(parent)
self.setupUi(self)
self.btn_start.clicked.connect(self.start_netlogo)
def start_netlogo(self):
self.netlogo = pyNetLogo.NetLogoLink(gui=True, thd=True
)
if __name__ == "__main__":
app = QApplication(sys.argv)
myWin = NetLogoWin()
myWin.show()
try:
r = app.exec_()
except Exception as err:
print(err)
Are there any solution to solve this? Thanks!
I suggest you take a look at the controlling guide for Netlogo as well as the API documentation.
I am not sure I fully understand what you are trying to achieve, but it seems you want to build a custom GUI using parts of the NetLogo application. If this interpretation is correct, then this is not the intended use case of the JAVA controlling API offered by NetLogo that is being used by PyNetLogo (and RNetlogo, for that matter).
I suggest you take a look at the controlling guide for Netlogo as well as the API documentation.
I am not sure I fully understand what you are trying to achieve, but it seems you want to build a custom GUI using parts of the NetLogo application. If this interpretation is correct, then this is not the intended use case of the JAVA controlling API offered by NetLogo that is being used by PyNetLogo (and RNetlogo, for that matter).
Thanks, the suggestions are helpful.