I’ve got a few questions on making my menu:
Image of my menu so far:
Q1:
I want to make borders around my main frame of the menu. I have not really seen anything on how to make a border going through the manual or I just did not see the section.
So if you can point me in the right direction that would be good!
Code for my main frame:
science_frame = DirectFrame(frameSize=(-0.7, 0.7, -0.4, 0.51), frameColor=(.23,.25,.24,.5), pos=(0,0,0))
In the image above the main frame is the whole menu you see.
Q2:
Is there an easy way to make borders around that span the whole menu as you see in the image Planet Name, Planet Type, Station.
I want it to span across the whole menu from left to right as it shows but I had to do it some sloppy way as in the code below to get this effect:
menu_header = OnscreenText(text = " PLANET NAME | PLANET TYPE | STATION | |", pos = (-0.7, 0.27), scale=(0.03, 0.03), fg=(1, 1, 1, 1), align=TextNode.ALeft, frame=(1,1,1,1)).reparentTo(planet_frame)
As you can see that code does not make sense to do it that way because I have this huge space that I need to do and use the | character to space it out.
Is there a way to do the same thing but without having to do it that way?
Q3:
As you see in the image Planet 1, Planet 2, etc. Is there a way to do borders around each of those as they are printed so they match up and align correctly and set a border width such as: Print this text here and then space like 10 spaces afterwards to here.
The code I use for printing out the planet names is this:
pos_x = -0.7
pos_y = 0.22
#Loop through as many times as there are planets and display the planet names
#Also spaces out the names by added .05 (or whatever looks best) to the y spacing (or z forget if screen coor are x and z or x and y but I still know what it does)
while counter <= num_of_planets:
OnscreenText(text = 'Planet %s |' %(counter), pos = (pos_x, pos_y), scale=(0.04, 0.04), fg=(1, 1, 1, 1), frame=(1,1,1,1), align=TextNode.ALeft)
pos_y = pos_y - 0.05
counter = counter + 1
I know there should be a better way so it prints out all nice sort of like how an excel spread sheet looks.
Q4:
Can I have just a border around my buttons? I know there is a way I read something about it but I couldent figure it out and or it just did not work.
This is my button code:
planet_button = DirectButton( text = ("PLANETS"), relief=None, text_fg=(1, 1, 1, 1), text_scale=(0.04, 0.04), pos=(-0.6, 0, 0.31) ).reparentTo(science_frame)
moon_button = DirectButton( text = ("MOONS"), relief=0, text_fg=(1, 1, 1, 1), text_scale=(0.04, 0.04), pos=(-0.4, 0, 0.31) ).reparentTo(science_frame)
research_button = DirectButton( text = ("RESEARCH"), relief=0, text_fg=(1, 1, 1, 1), text_scale=(0.04, 0.04), pos=(-0.18, 0, 0.31) ).reparentTo(science_frame)
So any help would be great! Still new to panda but learing as I go and having fun!
Here is my full code just incase you need it and please feel free to tell me how I could do anything in my code better (as long as its not too complex as still being new lol)
def science_menu():
from direct.gui.DirectGui import *
from direct.gui.OnscreenText import OnscreenText
from pandac.PandaModules import TextNode
science_frame = DirectFrame(frameSize=(-0.7, 0.7, -0.4, 0.51), frameColor=(.23,.25,.24,.5), pos=(0,0,0))
#planet_frame = DirectFrame(frameSize=(-0.7, 0.7, -0.4, 0.3), frameColor=(.23,.25,.24,1), pos=(0,0,0))
#moon_frame = DirectFrame(frameSize=(-0.7, 0.7, -0.4, 0.3), frameColor=(.23,.25,.24,1), pos=(0,0,0))
#research_frame = DirectFrame(frameSize=(-0.7, 0.7, -0.4, 0.3), frameColor=(.23,.25,.24,1), pos=(0,0,0))
planet_button = DirectButton( text = ("PLANETS"), relief=None, text_fg=(1, 1, 1, 1), text_scale=(0.04, 0.04), pos=(-0.6, 0, 0.31) ).reparentTo(science_frame)
moon_button = DirectButton( text = ("MOONS"), relief=0, text_fg=(1, 1, 1, 1), text_scale=(0.04, 0.04), pos=(-0.4, 0, 0.31) ).reparentTo(science_frame)
research_button = DirectButton( text = ("RESEARCH"), relief=0, text_fg=(1, 1, 1, 1), text_scale=(0.04, 0.04), pos=(-0.18, 0, 0.31) ).reparentTo(science_frame)
menu_header = OnscreenText(text = "Science & Industry", pos = (-0.21, 0.40), scale=(0.065, 0.065), fg=(1, 1, 1, 1))
#Create the buttons, frames, and text for the menu and position it
science_image = OnscreenImage(image = 'eve_rts/menu/gui/science_images/science_ind.jpg', pos=(-0.6, 0, 0.43), scale=(.08,.07,.07)).reparentTo(science_frame)
#Display the Planets frame, This can probaly be made into its own function
#Get the number of planets in the system
num_of_planets = len(base.planets)
#Create a frame for the planet info
planet_frame = DirectFrame(frameSize=(-0.7, 0.7, -0.4, 0.3), frameColor=(.23,.25,.24,1), pos=(0,0,0))
#Create the planet frame header. Using cheep way to space it out until I can figure out how to do it a better way...
menu_header = OnscreenText(text = " PLANET NAME | PLANET TYPE | STATION | |", pos = (-0.7, 0.27), scale=(0.03, 0.03), fg=(1, 1, 1, 1), align=TextNode.ALeft, frame=(1,1,1,1)).reparentTo(planet_frame)
#Make a counter for the while loop and set the position for the first planet name to display
counter = 1
pos_x = -0.7
pos_y = 0.22
#Loop through as many times as there are planets and display the planet names
#Also spaces out the names by added .05 (or whatever looks best) to the y spacing (or z forget if screen coor are x and z or x and y but I still know what it does)
while counter <= num_of_planets:
OnscreenText(text = 'Planet %s |' %(counter), pos = (pos_x, pos_y), scale=(0.04, 0.04), fg=(1, 1, 1, 1), frame=(1,1,1,1), align=TextNode.ALeft)
pos_y = pos_y - 0.05
counter = counter + 1