Jump to content
Korean Random
SV_Kirov

Как создать форму(Окно) в ангаре

Recommended Posts

Может кто показать как вывести на форму значение взятые c api через скрипт Python? 

Edited by Deno

Share this post


Link to post

Short link
Share on other sites

Может кто показать как вывести на форму значение взятые c api через скрипт Python? 

На несколько постов выше на ваш вопрос ответ

http://www.koreanrandom.com/forum/topic/25477-как-создать-формуокно-в-ангаре/?p=285620

http://www.koreanrandom.com/forum/topic/25477-как-создать-формуокно-в-ангаре/?p=285633

Edited by SV43

Share this post


Link to post

Short link
Share on other sites

Как определить this.startF(); и this.ontextFieldTest ?

package
{
   import flash.events.*;
   import flash.display.*;
   import scaleform.clik.core.UIComponent;
   import net.wg.infrastructure.base.AbstractWindowView;
  
   import net.wg.gui.components.controls.SoundButton;
   import flash.text.TextField;
  
   public class TestWindow extends AbstractWindowView
   {
   public var testF:Function = null;
   public var textFieldTest:TextField;
  
   public function as_setText(param:String):void
   {
   this.textFieldTest.htmlText = param;
   }
      public function TestWindow()
      {
         super();
      }
      override protected function configUI() : void
      {
         super.configUI();
  
   this.textFieldTest = new TextField();
   this.textFieldTest.width = 590;
   this.textFieldTest.height = 360;
   this.textFieldTest.x = 5;
   this.textFieldTest.y = 0;
   this.textFieldTest.multiline = true;
   this.textFieldTest.selectable = false;
   this.startF();
  
   this.addChild(this.textFieldTest);
   this.textFieldTest.addEventListener(MouseEvent.CLICK, this.ontextFieldTest);
      }
      override protected function onPopulate() : void
      {
         super.onPopulate();
         this.width = 600;
         this.height = 400;
         this.window.title = "Test Window";
      }
      override protected function onDispose() : void
      {
         super.onDispose();
      }
   }
}

Ошибки:

Error: Call to a possibly undefined method startF through a reference with static type TestWindow.

Error: Access of possibly undefined property ontextFieldTest through a reference with static type TestWindow.

 

Share this post


Link to post

Short link
Share on other sites

Снова где то накосячил. Все скомпилировалось но сообщения не вывелось + крестик съехал)))

 

'Скрин'

rcbdma15majc.png

 

'TestWindows.py'

from gui.Scaleform.framework import g_entitiesFactories, ViewSettings
from gui.Scaleform.framework import ViewTypes, ScopeTemplates
from gui.Scaleform.daapi.view.meta.WindowViewMeta import *
from gui.Scaleform.daapi import LobbySubView
from gui.WindowsManager import g_windowsManager
from gui.shared.utils.key_mapping import getBigworldNameFromKey
from gui.Scaleform.framework.entities.View import View

class TestWindow(LobbySubView, WindowViewMeta):

    def __init__(self):
        View.__init__(self)

    def _populate(self):
        View._populate(self)

    def onWindowClose(self):
        self.destroy()
  
    def onTryClosing(self):
        return True

def as_setTextS(self):
  if self._isDAAPIInited():
   return self.flashObject.as_setText('<font color="#FFFFFF">Hello World!</font>')

def startF(self):
  self.as_setTextS()


_alias = 'TestWindow'
_url = 'TestWindow.swf'
_type = ViewTypes.WINDOW
_event = None
_scope = ScopeTemplates.DEFAULT_SCOPE


_settings = ViewSettings(_alias, TestWindow, _url, _type, _event, _scope)
g_entitiesFactories.addSettings(_settings)

def onhandleKeyEvent(event):
    key = getBigworldNameFromKey(event.key)
    if key == 'KEY_F10':
        g_windowsManager.window.loadView('TestWindow', 'TestWindow')
    return None

from gui import InputHandler
InputHandler.g_instance.onKeyDown += onhandleKeyEvent

'TestWindows.as'

package
{
   import flash.events.*;
   import flash.display.*;
   import scaleform.clik.core.UIComponent;
   import net.wg.infrastructure.base.AbstractWindowView;
  
   import net.wg.gui.components.controls.SoundButton;
   import flash.text.TextField;
  
   public class TestWindow extends AbstractWindowView
   {

  public var textFieldTest:TextField;
  private var startF:Function;
  
  public function as_setText(param:String):void
  {
   this.textFieldTest.htmlText = param;
  }
  public function TestWindow()
  {
   super();
  }
  override protected function configUI() : void
  {
   super.configUI();
  
   this.textFieldTest = new TextField();
   this.textFieldTest.width = 590;
   this.textFieldTest.height = 360;
   this.textFieldTest.x = 5;
   this.textFieldTest.y = 0;
   this.textFieldTest.multiline = true;
   this.textFieldTest.selectable = false;
   this.startF();
  
   this.addChild(this.textFieldTest);
  }
  override protected function onPopulate() : void
  {
   super.onPopulate();
   this.width = 600;
   this.height = 400;
   this.window.title = "Test Window";
  }
  override protected function onDispose() : void
  {
   super.onDispose();
  }
   }
}

Edited by Mr.Deno

Share this post


Link to post

Short link
Share on other sites

,Повнимательнее прочитайте мое сообщение выше

Нет тот код от питона выложил и еще тот стер ((( щя переделаю отпишусь

 

Выложил код, там наверное путаница с именами функций 

 

вот эта часть меня смущает: 

def testF(self, param1):
   print param1

Этот кусок удалил так как он по ходу не нужен хз где его я взял 

Смещения крестика происходит из за this.startF(); если не ошибаюсь эта функция должна выводит текст   

 

'Смещения крестика'

rcbdma15majc.png

p.s Я вообще уже перестал понимать что к чему и как вывести текст. 

Edited by Mr.Deno

Share this post


Link to post

Short link
Share on other sites

'TestWindows.as'

package
{
import flash.events.*;
import flash.display.*;
import scaleform.clik.core.UIComponent;
import net.wg.infrastructure.base.AbstractWindowView;
import net.wg.gui.components.controls.ResizableScrollPane;
import net.wg.gui.components.controls.ScrollPane;
import net.wg.gui.components.controls.SoundButton;
import flash.text.TextField;
import net.wg.gui.components.advanced.ContentTabBar;
import scaleform.clik.core.UIComponent;

public class TestWindow extends AbstractWindowView
{

public var textFieldTest:TextField;
public var testScrollPane:ScrollPane;
public var ContentTab:ContentTabBar;


public var startF:Function;
public function as_setText(param:String):void
{
this.textFieldTest.htmlText = param;
}

public function TestWindow()
{
super();
}

override protected function configUI() : void
{
super.configUI();
this.textFieldTest = new TextField();
this.textFieldTest.width = 500;
this.textFieldTest.height = 550;
this.textFieldTest.x = 5;
this.textFieldTest.y = 0;
this.textFieldTest.multiline = true;
this.textFieldTest.selectable = false;
this.startF();
this.addChild(this.textFieldTest);
this.textFieldTest.addEventListener(MouseEvent.CLICK, this.ontextFieldTest);


}


override protected function onPopulate() : void
{
super.onPopulate();
this.width = 600;
this.height = 400;
this.window.title = "Test Window";
}
override protected function onDispose() : void
{
super.onDispose();
}



private function ontextFieldTest(event:MouseEvent) : void
{

}


}
}

 

'TestWindows.ry'

from gui.Scaleform.framework import g_entitiesFactories, ViewSettings
from gui.Scaleform.framework import ViewTypes, ScopeTemplates
from gui.Scaleform.daapi.view.meta.WindowViewMeta import *
from gui.Scaleform.daapi import LobbySubView
from gui.WindowsManager import g_windowsManager
from gui.shared.utils.key_mapping import getBigworldNameFromKey
from gui.Scaleform.framework.entities.View import View



class TestWindow(LobbySubView, WindowViewMeta):
    

    def __init__(self):
        View.__init__(self)

    def _populate(self):
        View._populate(self)


    def as_setTextS(self):
        if self._isDAAPIInited():
            text = urlopen('Hello World').read()

    def onWindowClose(self):
        self.destroy()

    def onTryClosing(self):
        return True

    def startF(self):
        self.as_setTextS()  


_alias = 'TestWindow'
_url = 'TestWindow.swf'
_type = ViewTypes.WINDOW
_event = None
_scope = ScopeTemplates.DEFAULT_SCOPE


_settings = ViewSettings(_alias, TestWindow, _url, _type, _event, _scope)
g_entitiesFactories.addSettings(_settings)


def onhandleKeyEvent(event):
    key = getBigworldNameFromKey(event.key)
    if key == 'KEY_F10':
        g_windowsManager.window.loadView('TestWindow', 'TestWindow')
    return None

from gui import InputHandler
InputHandler.g_instance.onKeyDown += onhandleKeyEvent


Mr.Deno, У тебя где то косяк в swf

Edited by SV_Kirov
  • Upvote 1

Share this post


Link to post

Short link
Share on other sites

TestWindows.as

package
{
import flash.events.*;
import flash.display.*;
import scaleform.clik.core.UIComponent;
import net.wg.infrastructure.base.AbstractWindowView;
import net.wg.gui.components.controls.ResizableScrollPane;
import net.wg.gui.components.controls.ScrollPane;
import net.wg.gui.components.controls.SoundButton;
import flash.text.TextField;
import net.wg.gui.components.advanced.ContentTabBar;
import scaleform.clik.core.UIComponent;

public class TestWindow extends AbstractWindowView
{

public var textFieldTest:TextField;
public var testScrollPane:ScrollPane;
public var ContentTab:ContentTabBar;


public var startF:Function;
public function as_setText(param:String):void
{
this.textFieldTest.htmlText = param;
}

public function TestWindow()
{
super();
}

override protected function configUI() : void
{
super.configUI();
this.textFieldTest = new TextField();
this.textFieldTest.width = 500;
this.textFieldTest.height = 550;
this.textFieldTest.x = 5;
this.textFieldTest.y = 0;
this.textFieldTest.multiline = true;
this.textFieldTest.selectable = false;
this.startF();
this.addChild(this.textFieldTest);
this.textFieldTest.addEventListener(MouseEvent.CLICK, this.ontextFieldTest);


}


override protected function onPopulate() : void
{
super.onPopulate();
this.width = 600;
this.height = 400;
this.window.title = "Test Window";
}
override protected function onDispose() : void
{
super.onDispose();
}



private function ontextFieldTest(event:MouseEvent) : void
{

}


}
}

 

TestWindows.ry

from gui.Scaleform.framework import g_entitiesFactories, ViewSettings
from gui.Scaleform.framework import ViewTypes, ScopeTemplates
from gui.Scaleform.daapi.view.meta.WindowViewMeta import *
from gui.Scaleform.daapi import LobbySubView
from gui.WindowsManager import g_windowsManager
from gui.shared.utils.key_mapping import getBigworldNameFromKey
from gui.Scaleform.framework.entities.View import View



class TestWindow(LobbySubView, WindowViewMeta):
    

    def __init__(self):
        View.__init__(self)

    def _populate(self):
        View._populate(self)


    def as_setTextS(self):
        if self._isDAAPIInited():
            text = urlopen('Hello World').read()

    def onWindowClose(self):
        self.destroy()

    def onTryClosing(self):
        return True

    def startF(self):
        self.as_setTextS()  


_alias = 'TestWindow'
_url = 'TestWindow.swf'
_type = ViewTypes.WINDOW
_event = None
_scope = ScopeTemplates.DEFAULT_SCOPE


_settings = ViewSettings(_alias, TestWindow, _url, _type, _event, _scope)
g_entitiesFactories.addSettings(_settings)


def onhandleKeyEvent(event):
    key = getBigworldNameFromKey(event.key)
    if key == 'KEY_F10':
        g_windowsManager.window.loadView('TestWindow', 'TestWindow')
    return None

from gui import InputHandler
InputHandler.g_instance.onKeyDown += onhandleKeyEvent

 

Mr.Deno, У тебя где то косяк в swf

 

 

Все отображает спасибо

Только 

text = urlopen('Hello World').read()

заменил на 

return self.flashObject.as_setText('<font color="#FFFFFF">Hello World</font>')

Edited by Mr.Deno

Share this post


Link to post

Short link
Share on other sites

 

Все отображает спасибо

Только 

text = urlopen('Hello World').read()

заменил на 

return self.flashObject.as_setText('<font color="#FFFFFF">Hello World</font>')

Точно, второй раз на одни и теже грабли. Думаю и исходнике было всё норм

Share this post


Link to post

Short link
Share on other sites

Как лучше сделать что бы можно было расположить нужные значения спаренные в нужной точки формы 

Пример: 

#обрабатывает  данные полученные через API WG

rsp = json.loads(req.text)

Данные в таком виде

{u'status': u'ok', u'meta': {u'count': 5}, u'data': [{u'nickname': u'Vampire00', u'account_id': 50805}, {u'nickname': u'vampire00000', u'account_id': 35007367}, {u'nickname': u'Vampire00022202', u'account_id': 23297229}, {u'nickname': u'Vampire0005', u'account_id': 3179509}, {u'nickname': u'Vampire0007', u'account_id': 2146788}]}

Выводим только nickname и id игроков

for i in rsp.get('data'):
    print 'name:', i.get('nickname'), ' id:', i.get('account_id')
       
test_print()

но если подставить 

return self.flashObject.as_setText('<font color="#FFFFFF">'+test_print()+'</font>')

ему так не нравиться. 

 

но и даже если бы сработало было бы коряво и не красиво. 

 

А я хочу что бы получилось примерно так:

 

h6fl4wcre2n8.png

p.s Может есть пример подобного или подскажите что почитать буду благодарен 

Edited by Mr.Deno

Share this post


Link to post

Short link
Share on other sites

как вариант можно попробовать html тегами, например табличку заюзать 

<table>
  <tr>
    <td>Name</td>
    <td>id</td>
  </tr>
  <tr>
    <td>Name2</td>
    <td>id2</td>
  </tr>
</table>

как то так

Share this post


Link to post

Short link
Share on other sites

вместо print используй return

Пробовал но тогда он выводит первую запись и все 

 

Вывести все записи у меня получилось только записать сначала в файл а потом вывести файл 

 

запись данных:

def test_print():
    f = open('c:\\text.txt', 'w')
    for i in rsp.get('data'):
        f.write("%s\n" % i.get('nickname'))
msg = open('c:\\text.txt','r').read()

вывод данных:

SystemMessages.pushMessage(msg, type)

Но так криво и мне не нравиться 

Edited by Mr.Deno

Share this post


Link to post

Short link
Share on other sites

конкатенируй строки

def test_print():
    str1 = ""
    for i in rsp.get('data'):
        str1 += "Nickname: %s Id: %s\n" % (i.get('nickname') , i.get('account_id'))
    return str1

 

В таком случаи проблемы с вывод решились спасибо (надо почитать про этот метод). А вот что на счет разметки, пытаться использовать html? 

Edited by Mr.Deno

Share this post


Link to post

Short link
Share on other sites

справочник по html найди в интернете.

как варианнт обновил сообщение выше

Всем спасибо за помощь буду пытаться дальше. 

Share this post


Link to post

Short link
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...