Having issues with DFrame and DButton, SetParent() not working properly..

I am trying to create a Derma Menu, but for some odd reason I can’t set the DFrame as Parent to the DButton.
Screenshot:

Now the button only shows when I set


local b1 = vgui.Create( 'DButton', 'base' )//Only when the *base* is in quotes the button shows up, without quotes it doesn't

Here’s the code I created:


function ph_tm_p1()
	local base = vgui.Create( 'DFrame' )		//Menu Frame
		base:SetSize(176, 571)
		base:SetPos(1728, 208)
		base:SetTitle('Taunts')
		base:SetDeleteOnClose(false)
		base:ShowCloseButton(false)
		base:MakePopup()
	local b1 = vgui.Create( 'DButton', 'base' )	//Button1
		b1:SetSize(150, 33)
		b1:SetPos(1741, 241)
		b1:SetText('Button1')
		b1.DoClick = function() end
end
concommand.Add("phtm",ph_tm_p1)

I even tried:


b1:SetParent( base ) //Button didn't show.
b1:SetParent( "base" ) //Button showed, but wasn't a part of the DFrame.

Could you give me a hint about he mistake I am doing?

Change:


local b1 = vgui.Create( 'DButton', 'base' )

To:


local b1 = vgui.Create( 'DButton', base )

The reason why the button doesn’t show up is because of your button positon(x&y).
Set it to 0,0 and then you can edit it from there.

[editline]10th October 2014[/editline]

Also it’s a really bad way to use pixels based positions if you don’t want it in the top right.
Take a look at ScrW() and ScrH()

Thank you! Much appreciated!

I want it to be in the middle of the Right side of the screen, so yea’… if you know how I appreciate the help.

Edit: How can I limit that the player can open the menu once?



local opened = false
function ph_tm_p1()
if ( opened ) then return end
opened = true
	local base = vgui.Create( 'DFrame' )		//Menu Frame
		base:SetSize(176, 571)
		base:SetPos(1728, 208)
		base:SetTitle('Taunts')
		base:SetDeleteOnClose(false)
		base:ShowCloseButton(false)
		base:MakePopup()
	local b1 = vgui.Create( 'DButton', base )	//Button1
		b1:SetSize(150, 33)
		b1:SetPos(1741, 241)
		b1:SetText('Button1')
		b1.DoClick = function() end
end
concommand.Add("phtm",ph_tm_p1)