AWTK环境搭建步骤及问题整理

1.环境搭建步骤:

1、在awtk的安装路径下,增加文件夹(即AWStudio目录下):python-3.6.6-amd64,

2、把python指定安装在这个路径下,C:\AWStudio\python-3.6.6-amd64;

3、在docs命令下进入到这个路径:C:\AWStudio\python-3.6.6-amd64 并输入:pip install scons

2.问题整理:

awtk scons报错: unsupported pickle protocol: 4
scons: Reading SConscript files …
scons: done reading SConscript files.
scons: Building targets …
scons: * [SConstruct] ValueError : unsupported pickle protocol: 4
scons: building terminated because of errors.
解决方式:删除项目根目录的 .sconsign.dblite 文件

3.设置字体大小:

widget_set_style_int(widget, "normal:font_size", 20);
  1. 设置和获取文本控件的内容:

char text[128] = {0};
widget_t* label = widget_lookup(win, "label", TRUE);
widget_set_prop_str(label, WIDGET_PROP_TEXT, "蓝牙设置");
memset(text, 0x0, sizeof(text) - 1);
widget_get_text_utf8(label, text, sizeof(text) - 1);
log_debug("###############################text:%s:\n", text);

2.图片值的使用:

AWTK环境搭建步骤及问题整理_第1张图片

报错信息:

image_value_draw_images:46 condition(widget_load_image(widget, bitmap_name[i], &b) == RET_OK) failed!

解决方式:在控件编辑器中的“杂项”中,把“auto_adjust_size”勾选的去掉。

static ret_t change_locale(const timer_info_t* timer) {
    char country[3];
    char language[3];
    printf("timer->ctx =%s\n", (char*)(timer->ctx));
    strncpy(language, (char*)(timer->ctx), 2);
    strncpy(country, (char*)(timer->ctx) +3, 2);
    locale_info_change(locale_info(), language, country);

    return RET_OK;
}
char* str[] = { "zh_CN" , "en_US" };
timer_queue(change_locale, str[0], 30);
/*******************************************************************/
static ret_t on_timer(const timer_info_t* timer) {
  return update_progress_bar(WIDGET(timer->ctx));
}
static ret_t on_idle(const idle_info_t* idle) {
  return update_progress_bar(WIDGET(idle->ctx));
}
void* thread_entry(void* args) {
  int nr = 500;
  while(nr-- > 0) {
    idle_queue(on_idle, args);
    timer_queue(on_timer, args, 30);
    sleep_ms(30);
  }
  return NULL;
}
static ret_t setting_switchover_animation(widget_t* win) 
{
    bool_t ret = FALSE;
    widget_t* setting_switchover = widget_lookup(win, "setting_switchover", TRUE);
    if (NULL != setting_switchover) {
        ret = image_animation_play(setting_switchover);
        if (RET_OK == ret) {
            if (FALSE == widget_get_visible(setting_switchover)) {
                widget_set_visible(setting_switchover, TRUE, FALSE);
            }
            while (!ret)
            {
                sleep_ms(10);
                ret = image_animation_is_playing(setting_switchover);
            }
            while (ret)
            {
                sleep_ms(10);
                ret = image_animation_is_playing(setting_switchover);
            }
        }
    }
    return RET_OK;
}
/**
 * 主题背景延迟淡入
 */
static ret_t on_bkgnd_delay_in(const timer_info_t* timer) {
  widget_t* bkgnd = WIDGET(timer->ctx);

  if (bkgnd != NULL) {
    widget_start_animator(bkgnd, "fade_in");
    bkgnd_change(bkgnd);
  }

  return RET_REMOVE;
}

/**
 * 更新主题背景(淡出淡入)
 */
static ret_t on_bkgnd_update(const timer_info_t* timer) {
  widget_t* win = WIDGET(timer->ctx);
  widget_t* bkgnd = widget_lookup(win, "bkgnd", TRUE);

  if (bkgnd) {
#ifdef WITH_BKGND_FADE
    widget_start_animator(bkgnd, "fade_out");
    widget_add_timer(bkgnd, on_bkgnd_delay_in, 500);
#else
    bkgnd_change(bkgnd);
#endif
  }

  return RET_REPEAT;
}
widget_t* image_animation = image_animation_create(win, 0, 0, 1280, 720);
image_animation_set_image(image_animation, "setting_change");
image_animation_set_interval(image_animation, 0);
image_animation_set_range_sequence(image_animation, 1, 7);
image_animation_set_loop(image_animation, FALSE);
image_animation_set_unload_after_paint(image_animation, TRUE);
image_animation_play(image_animation);

多套主题:

  1. 新建的主题名字和新建窗口名字要相同;

  1. 在xml中添加主图名字:

theme="default">

  1. widget_set_theme(window_manager(), "default");

navigator_to("default");

你可能感兴趣的:(软件开发,awtk)